ProgramCounterHandler: emit branches separately

When generating a conditional branch with fallthrough and `anyPC`
basic block, make sure branches are emitted in distinct blocks.
This commit is contained in:
Antonio Frighetto
2021-08-30 11:30:00 +02:00
parent ab597dc52f
commit bdf27e929d
+11 -1
View File
@@ -851,5 +851,15 @@ void PCH::buildHotPath(IRBuilder<> &B,
CreateCmp(TypeCSV, Address.type()),
CreateCmp(AddressCSV, Address.address()) };
auto *Condition = B.CreateAnd(ToAnd);
B.CreateCondBr(Condition, BB, Default);
// Emit branches of targets in dedicated basic blocks. As of now,
// IsolateFunction struggles with basic blocks that are both direct and
// indirect at the same time. This allows the pass to execute correctly.
auto *JumpToBB = BasicBlock::Create(B.getContext(), "", BB->getParent());
auto *JumpToDefault = BasicBlock::Create(B.getContext(), "", BB->getParent());
BranchInst::Create(BB, JumpToBB);
BranchInst::Create(Default, JumpToDefault);
B.CreateCondBr(Condition, JumpToBB, JumpToDefault);
}