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) {
// Create the fallthrough jump
uint64_t NextPC = JTM->getNextPC(Call);
Value *NextPCConst = Builder.getIntN(PCRegTy->getIntegerBitWidth(), NextPC);
Builder.CreateCondBr(Builder.CreateICmpEQ(Builder.CreateLoad(PCReg),
NextPCConst),
JTM->registerJT(NextPC, JTReason::PostHelper),
JTM->anyPC());
// Get the fallthrough basic block and emit a conditional branch, if not
// possible simply jump to 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;
}
......
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