From c7cac31b88f03f5a108d31c5bcedbe5846b89f54 Mon Sep 17 00:00:00 2001 From: Hyxogen <8938732+Hyxogen@users.noreply.github.com> Date: Wed, 7 Feb 2024 10:43:52 +0100 Subject: [PATCH 1/2] partialexecuter: increment and check basicblock visit count after terminals --- llvm/lib/CheerpWriter/PartialExecuter.cpp | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/llvm/lib/CheerpWriter/PartialExecuter.cpp b/llvm/lib/CheerpWriter/PartialExecuter.cpp index c68c26e4ca4e..220b702d8daf 100644 --- a/llvm/lib/CheerpWriter/PartialExecuter.cpp +++ b/llvm/lib/CheerpWriter/PartialExecuter.cpp @@ -1701,18 +1701,20 @@ void PartialInterpreter::visitOuter(FunctionData& data, llvm::Instruction& I) if (next) { - // We know where execution should proceed - incomingBB = I.getParent(); - getTopCallFrame().CurBB = next; - getTopCallFrame().CurInst = getTopCallFrame().CurBB->begin(); + data.incrementVisitCounter(next); - // Also here we have set the proper state for the execution so we can return - return; - } - else - { - skip = true; + if (data.getVisitCounter(next) < MAX_NUMBER_OF_VISITS_PER_BB) + { + // We know where execution should proceed + incomingBB = I.getParent(); + getTopCallFrame().CurBB = next; + getTopCallFrame().CurInst = getTopCallFrame().CurBB->begin(); + + // Also here we have set the proper state for the execution so we can return + return; + } } + skip = true; } if (addToCounter(I.getFunction())) From b1ddbffbe1edac870fb3c4f7dbd429ea735c6018 Mon Sep 17 00:00:00 2001 From: Hyxogen <8938732+Hyxogen@users.noreply.github.com> Date: Thu, 8 Feb 2024 07:59:35 +0100 Subject: [PATCH 2/2] fixup! partialexecuter: increment and check basicblock visit count after terminals --- llvm/lib/CheerpWriter/PartialExecuter.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/llvm/lib/CheerpWriter/PartialExecuter.cpp b/llvm/lib/CheerpWriter/PartialExecuter.cpp index 220b702d8daf..667cc2942091 100644 --- a/llvm/lib/CheerpWriter/PartialExecuter.cpp +++ b/llvm/lib/CheerpWriter/PartialExecuter.cpp @@ -1699,20 +1699,17 @@ void PartialInterpreter::visitOuter(FunctionData& data, llvm::Instruction& I) { BasicBlock* next = findNextBasicBlock(I); - if (next) + if (next && data.getVisitCounter(next) < MAX_NUMBER_OF_VISITS_PER_BB) { data.incrementVisitCounter(next); - if (data.getVisitCounter(next) < MAX_NUMBER_OF_VISITS_PER_BB) - { - // We know where execution should proceed - incomingBB = I.getParent(); - getTopCallFrame().CurBB = next; - getTopCallFrame().CurInst = getTopCallFrame().CurBB->begin(); + // We know where execution should proceed + incomingBB = I.getParent(); + getTopCallFrame().CurBB = next; + getTopCallFrame().CurInst = getTopCallFrame().CurBB->begin(); - // Also here we have set the proper state for the execution so we can return - return; - } + // Also here we have set the proper state for the execution so we can return + return; } skip = true; }