Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BOLT][NFC] Rename isUnsupportedBranch to isReversibleBranch #92447

Merged
merged 1 commit into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions bolt/include/bolt/Core/MCPlusBuilder.h
Original file line number Diff line number Diff line change
Expand Up @@ -438,8 +438,8 @@ class MCPlusBuilder {
return false;
}

/// Check whether we support inverting this branch
virtual bool isUnsupportedBranch(const MCInst &Inst) const { return false; }
/// Check whether this conditional branch can be reversed
virtual bool isReversibleBranch(const MCInst &Inst) const { return true; }

/// Return true of the instruction is of pseudo kind.
virtual bool isPseudo(const MCInst &Inst) const {
Expand Down
4 changes: 2 additions & 2 deletions bolt/lib/Core/BinaryFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1284,7 +1284,7 @@ Error BinaryFunction::disassemble() {
const bool IsCondBranch = MIB->isConditionalBranch(Instruction);
MCSymbol *TargetSymbol = nullptr;

if (BC.MIB->isUnsupportedBranch(Instruction)) {
if (!BC.MIB->isReversibleBranch(Instruction)) {
setIgnored();
if (BinaryFunction *TargetFunc =
BC.getBinaryFunctionContainingAddress(TargetAddress))
Expand Down Expand Up @@ -3384,7 +3384,7 @@ void BinaryFunction::fixBranches() {

// Reverse branch condition and swap successors.
auto swapSuccessors = [&]() {
if (MIB->isUnsupportedBranch(*CondBranch)) {
if (!MIB->isReversibleBranch(*CondBranch)) {
if (opts::Verbosity) {
BC.outs() << "BOLT-INFO: unable to swap successors in " << *this
<< '\n';
Expand Down
2 changes: 1 addition & 1 deletion bolt/lib/Passes/Instrumentation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ void Instrumentation::instrumentFunction(BinaryFunction &Function,
else if (BC.MIB->isUnconditionalBranch(Inst))
HasUnconditionalBranch = true;
else if ((!BC.MIB->isCall(Inst) && !BC.MIB->isConditionalBranch(Inst)) ||
BC.MIB->isUnsupportedBranch(Inst))
!BC.MIB->isReversibleBranch(Inst))
continue;

const uint32_t FromOffset = *BC.MIB->getOffset(Inst);
Expand Down
10 changes: 5 additions & 5 deletions bolt/lib/Target/X86/X86MCPlusBuilder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -328,19 +328,19 @@ class X86MCPlusBuilder : public MCPlusBuilder {
return false;
}

bool isUnsupportedBranch(const MCInst &Inst) const override {
bool isReversibleBranch(const MCInst &Inst) const override {
if (isDynamicBranch(Inst))
return true;
return false;

switch (Inst.getOpcode()) {
default:
return false;
return true;
case X86::LOOP:
case X86::LOOPE:
case X86::LOOPNE:
case X86::JECXZ:
case X86::JRCXZ:
return true;
return false;
}
}

Expand Down Expand Up @@ -1874,7 +1874,7 @@ class X86MCPlusBuilder : public MCPlusBuilder {
}

// Handle conditional branches and ignore indirect branches
if (!isUnsupportedBranch(*I) && getCondCode(*I) == X86::COND_INVALID) {
if (isReversibleBranch(*I) && getCondCode(*I) == X86::COND_INVALID) {
// Indirect branch
return false;
}
Expand Down
Loading