From: Amir Ayupov Date: Wed, 18 Jan 2023 02:26:34 +0000 (-0800) Subject: [BOLT][NFC] Remove AArch64 override for evaluateBranch X-Git-Tag: upstream/17.0.6~20519 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=706606a7df60eb54281dee6e379929b9df34b427;p=platform%2Fupstream%2Fllvm.git [BOLT][NFC] Remove AArch64 override for evaluateBranch Use MCInstrAnalysis implementation Reviewed By: #bolt, rafauler, yota9 Differential Revision: https://reviews.llvm.org/D141983 --- diff --git a/bolt/include/bolt/Core/MCPlusBuilder.h b/bolt/include/bolt/Core/MCPlusBuilder.h index dd91f25..c4d3f78 100644 --- a/bolt/include/bolt/Core/MCPlusBuilder.h +++ b/bolt/include/bolt/Core/MCPlusBuilder.h @@ -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. diff --git a/bolt/lib/Core/MCPlusBuilder.cpp b/bolt/lib/Core/MCPlusBuilder.cpp index c43ca5e..c83112f 100644 --- a/bolt/lib/Core/MCPlusBuilder.cpp +++ b/bolt/lib/Core/MCPlusBuilder.cpp @@ -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)) diff --git a/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp b/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp index bd9ed8f..e6323ee 100644 --- a/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp +++ b/bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp @@ -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) &&