[BOLT][NFC] Remove AArch64 override for evaluateBranch
authorAmir Ayupov <aaupov@fb.com>
Wed, 18 Jan 2023 02:26:34 +0000 (18:26 -0800)
committerAmir Ayupov <aaupov@fb.com>
Wed, 18 Jan 2023 21:22:57 +0000 (13:22 -0800)
Use MCInstrAnalysis implementation

Reviewed By: #bolt, rafauler, yota9

Differential Revision: https://reviews.llvm.org/D141983

bolt/include/bolt/Core/MCPlusBuilder.h
bolt/lib/Core/MCPlusBuilder.cpp
bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

index dd91f25..c4d3f78 100644 (file)
@@ -822,7 +822,9 @@ public:
   /// \brief Given a branch instruction try to get the address the branch
   /// targets. Return true on success, and the address in Target.
   virtual bool evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size,
-                              uint64_t &Target) const;
+                              uint64_t &Target) const {
+    return Analysis->evaluateBranch(Inst, Addr, Size, Target);
+  }
 
   /// Return true if one of the operands of the \p Inst instruction uses
   /// PC-relative addressing.
index c43ca5e..c83112f 100644 (file)
@@ -321,11 +321,6 @@ void MCPlusBuilder::printAnnotations(const MCInst &Inst,
   }
 }
 
-bool MCPlusBuilder::evaluateBranch(const MCInst &Inst, uint64_t Addr,
-                                   uint64_t Size, uint64_t &Target) const {
-  return Analysis->evaluateBranch(Inst, Addr, Size, Target);
-}
-
 void MCPlusBuilder::getClobberedRegs(const MCInst &Inst,
                                      BitVector &Regs) const {
   if (isPrefix(Inst) || isCFI(Inst))
index bd9ed8f..e6323ee 100644 (file)
@@ -435,34 +435,6 @@ public:
     return getTargetAddend(Op.getExpr());
   }
 
-  bool evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size,
-                      uint64_t &Target) const override {
-    size_t OpNum = 0;
-
-    if (isConditionalBranch(Inst)) {
-      assert(MCPlus::getNumPrimeOperands(Inst) >= 2 &&
-             "Invalid number of operands");
-      OpNum = 1;
-    }
-
-    if (isTB(Inst)) {
-      assert(MCPlus::getNumPrimeOperands(Inst) >= 3 &&
-             "Invalid number of operands");
-      OpNum = 2;
-    }
-
-    if (Info->get(Inst.getOpcode()).OpInfo[OpNum].OperandType !=
-        MCOI::OPERAND_PCREL) {
-      assert((isIndirectBranch(Inst) || isIndirectCall(Inst)) &&
-             "FAILED evaluateBranch");
-      return false;
-    }
-
-    int64_t Imm = Inst.getOperand(OpNum).getImm() << 2;
-    Target = Addr + Imm;
-    return true;
-  }
-
   bool replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
                            MCContext *Ctx) const override {
     assert((isCall(Inst) || isBranch(Inst)) && !isIndirectBranch(Inst) &&