Skip to content

Commit b0e2be9

Browse files
Bill Nellmemfrob
authored andcommitted
[BOLT] Always call fixBranches in relocation mode.
Summary: If you attempted to use a function filter on a binary when in relocation mode, the resulting binary would probably crash. This is because we weren't calling fixBranches on all functions. This was breaking bughunter.sh I also strengthened the validation of basic blocks. The cond branch should always be non-null when there are two successors. (cherry picked from FBD6261930)
1 parent ec7e92a commit b0e2be9

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

bolt/BinaryBasicBlock.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,7 @@ bool BinaryBasicBlock::validateSuccessorInvariants() {
104104
break;
105105
case 2:
106106
Valid =
107-
(!CondBranch ||
107+
(CondBranch &&
108108
(TBB == getConditionalSuccessor(true)->getLabel() &&
109109
((!UncondBranch && !FBB) ||
110110
(UncondBranch &&

bolt/Passes/BinaryPasses.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ void FixupBranches::runOnFunctions(
516516
std::set<uint64_t> &) {
517517
for (auto &It : BFs) {
518518
auto &Function = It.second;
519-
if (shouldOptimize(Function)) {
519+
if (opts::Relocs || shouldOptimize(Function)) {
520520
Function.fixBranches();
521521
}
522522
}

0 commit comments

Comments
 (0)