[BOLT] Enhance fixed indirect branch handling (#71324)

Previously HasFixedIndirectBranch was set in BF to set isSimple to false
later because of unreachable bb ellimination pass which might remove the
BB with it's symbols accessed by other instructions than calls. It seems
to be that better solution would be to add extra entry point on target
offset instead of marking BF as non-simple.
This commit is contained in:
Vladislav Khmelevsky 2023-11-16 09:30:55 +04:00 committed by GitHub
parent 291f4a0023
commit 5b59540661
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 1 additions and 10 deletions

View File

@ -319,10 +319,6 @@ private:
/// Execution halts whenever this function is entered.
bool TrapsOnEntry{false};
/// True if the function had an indirect branch with a fixed internal
/// destination.
bool HasFixedIndirectBranch{false};
/// True if the function is a fragment of another function. This means that
/// this function could only be entered via its parent or one of its sibling
/// fragments. It could be entered at any basic block. It can also return

View File

@ -432,8 +432,6 @@ void BinaryFunction::print(raw_ostream &OS, std::string Annotation) {
OS << "\n IsSplit : " << isSplit();
OS << "\n BB Count : " << size();
if (HasFixedIndirectBranch)
OS << "\n HasFixedIndirectBranch : true";
if (HasUnknownControlFlow)
OS << "\n Unknown CF : true";
if (getPersonalityFunction())
@ -1118,7 +1116,7 @@ void BinaryFunction::handleIndirectBranch(MCInst &Instruction, uint64_t Size,
Instruction.clear();
MIB->createUncondBranch(Instruction, TargetSymbol, BC.Ctx.get());
TakenBranches.emplace_back(Offset, IndirectTarget - getAddress());
HasFixedIndirectBranch = true;
addEntryPointAtOffset(IndirectTarget - getAddress());
} else {
MIB->convertJmpToTailCall(Instruction);
BC.addInterproceduralReference(this, IndirectTarget);
@ -1894,9 +1892,6 @@ bool BinaryFunction::postProcessIndirectBranches(
LastIndirectJumpBB->updateJumpTableSuccessors();
}
if (HasFixedIndirectBranch)
return false;
// Validate that all data references to function offsets are claimed by
// recognized jump tables. Register externally referenced blocks as entry
// points.