Skip to content
Snippets Groups Projects
Commit ffa035fc authored by Andrea Gussoni's avatar Andrea Gussoni Committed by Alessandro Di Federico
Browse files

Detect invalid fallthrough after helper

Fix for a situation where the fallthrough basic block of an instruction
calling a helper function is not in an executable segment and therefore
not created.
parent ce22b9c4
No related branches found
No related tags found
No related merge requests found
...@@ -298,10 +298,18 @@ bool TranslateDirectBranchesPass::forceFallthroughAfterHelper(CallInst *Call) { ...@@ -298,10 +298,18 @@ bool TranslateDirectBranchesPass::forceFallthroughAfterHelper(CallInst *Call) {
// Create the fallthrough jump // Create the fallthrough jump
uint64_t NextPC = JTM->getNextPC(Call); uint64_t NextPC = JTM->getNextPC(Call);
Value *NextPCConst = Builder.getIntN(PCRegTy->getIntegerBitWidth(), NextPC); Value *NextPCConst = Builder.getIntN(PCRegTy->getIntegerBitWidth(), NextPC);
Builder.CreateCondBr(Builder.CreateICmpEQ(Builder.CreateLoad(PCReg),
NextPCConst), // Get the fallthrough basic block and emit a conditional branch, if not
JTM->registerJT(NextPC, JTReason::PostHelper), // possible simply jump to anyPC
JTM->anyPC()); BasicBlock *NextPCBB = JTM->registerJT(NextPC, JTReason::PostHelper);
if (NextPCBB != nullptr) {
Builder.CreateCondBr(Builder.CreateICmpEQ(Builder.CreateLoad(PCReg),
NextPCConst),
NextPCBB,
JTM->anyPC());
} else {
Builder.CreateBr(JTM->anyPC());
}
return true; return true;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment