diff --git a/bolt/include/bolt/Core/MCPlusBuilder.h b/bolt/include/bolt/Core/MCPlusBuilder.h --- a/bolt/include/bolt/Core/MCPlusBuilder.h +++ b/bolt/include/bolt/Core/MCPlusBuilder.h @@ -434,7 +434,7 @@ } /// Check whether we support inverting this branch - virtual bool isUnsupportedBranch(unsigned Opcode) const { return false; } + virtual bool isUnsupportedBranch(const MCInst &Inst) const { return false; } /// Return true of the instruction is of pseudo kind. bool isPseudo(const MCInst &Inst) const { diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp --- a/bolt/lib/Core/BinaryFunction.cpp +++ b/bolt/lib/Core/BinaryFunction.cpp @@ -1250,7 +1250,7 @@ const bool IsCondBranch = MIB->isConditionalBranch(Instruction); MCSymbol *TargetSymbol = nullptr; - if (BC.MIB->isUnsupportedBranch(Instruction.getOpcode())) { + if (BC.MIB->isUnsupportedBranch(Instruction)) { setIgnored(); if (BinaryFunction *TargetFunc = BC.getBinaryFunctionContainingAddress(TargetAddress)) @@ -3262,8 +3262,7 @@ const BinaryBasicBlock *TSuccessor = BB->getConditionalSuccessor(true); const BinaryBasicBlock *FSuccessor = BB->getConditionalSuccessor(false); // Check whether we support reversing this branch direction - const bool IsSupported = - !MIB->isUnsupportedBranch(CondBranch->getOpcode()); + const bool IsSupported = !MIB->isUnsupportedBranch(*CondBranch); if (NextBB && NextBB == TSuccessor && IsSupported) { std::swap(TSuccessor, FSuccessor); { diff --git a/bolt/lib/Passes/Instrumentation.cpp b/bolt/lib/Passes/Instrumentation.cpp --- a/bolt/lib/Passes/Instrumentation.cpp +++ b/bolt/lib/Passes/Instrumentation.cpp @@ -381,7 +381,7 @@ else if (BC.MIB->isUnconditionalBranch(Inst)) HasUnconditionalBranch = true; else if ((!BC.MIB->isCall(Inst) && !BC.MIB->isConditionalBranch(Inst)) || - BC.MIB->isUnsupportedBranch(Inst.getOpcode())) + BC.MIB->isUnsupportedBranch(Inst)) continue; const uint32_t FromOffset = *BC.MIB->getOffset(Inst); diff --git a/bolt/lib/Target/X86/X86MCPlusBuilder.cpp b/bolt/lib/Target/X86/X86MCPlusBuilder.cpp --- a/bolt/lib/Target/X86/X86MCPlusBuilder.cpp +++ b/bolt/lib/Target/X86/X86MCPlusBuilder.cpp @@ -318,8 +318,8 @@ return false; } - bool isUnsupportedBranch(unsigned Opcode) const override { - switch (Opcode) { + bool isUnsupportedBranch(const MCInst &Inst) const override { + switch (Inst.getOpcode()) { default: return false; case X86::LOOP: @@ -1860,8 +1860,7 @@ } // Handle conditional branches and ignore indirect branches - if (!isUnsupportedBranch(I->getOpcode()) && - getCondCode(*I) == X86::COND_INVALID) { + if (!isUnsupportedBranch(*I) && getCondCode(*I) == X86::COND_INVALID) { // Indirect branch return false; }