Skip to content

Commit 706606a

Browse files
committed
[BOLT][NFC] Remove AArch64 override for evaluateBranch
Use MCInstrAnalysis implementation Reviewed By: #bolt, rafauler, yota9 Differential Revision: https://reviews.llvm.org/D141983
1 parent 1136cf1 commit 706606a

File tree

3 files changed

+3
-34
lines changed

3 files changed

+3
-34
lines changed

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -822,7 +822,9 @@ class MCPlusBuilder {
822822
/// \brief Given a branch instruction try to get the address the branch
823823
/// targets. Return true on success, and the address in Target.
824824
virtual bool evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size,
825-
uint64_t &Target) const;
825+
uint64_t &Target) const {
826+
return Analysis->evaluateBranch(Inst, Addr, Size, Target);
827+
}
826828

827829
/// Return true if one of the operands of the \p Inst instruction uses
828830
/// PC-relative addressing.

bolt/lib/Core/MCPlusBuilder.cpp

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -321,11 +321,6 @@ void MCPlusBuilder::printAnnotations(const MCInst &Inst,
321321
}
322322
}
323323

324-
bool MCPlusBuilder::evaluateBranch(const MCInst &Inst, uint64_t Addr,
325-
uint64_t Size, uint64_t &Target) const {
326-
return Analysis->evaluateBranch(Inst, Addr, Size, Target);
327-
}
328-
329324
void MCPlusBuilder::getClobberedRegs(const MCInst &Inst,
330325
BitVector &Regs) const {
331326
if (isPrefix(Inst) || isCFI(Inst))

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -435,34 +435,6 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
435435
return getTargetAddend(Op.getExpr());
436436
}
437437

438-
bool evaluateBranch(const MCInst &Inst, uint64_t Addr, uint64_t Size,
439-
uint64_t &Target) const override {
440-
size_t OpNum = 0;
441-
442-
if (isConditionalBranch(Inst)) {
443-
assert(MCPlus::getNumPrimeOperands(Inst) >= 2 &&
444-
"Invalid number of operands");
445-
OpNum = 1;
446-
}
447-
448-
if (isTB(Inst)) {
449-
assert(MCPlus::getNumPrimeOperands(Inst) >= 3 &&
450-
"Invalid number of operands");
451-
OpNum = 2;
452-
}
453-
454-
if (Info->get(Inst.getOpcode()).OpInfo[OpNum].OperandType !=
455-
MCOI::OPERAND_PCREL) {
456-
assert((isIndirectBranch(Inst) || isIndirectCall(Inst)) &&
457-
"FAILED evaluateBranch");
458-
return false;
459-
}
460-
461-
int64_t Imm = Inst.getOperand(OpNum).getImm() << 2;
462-
Target = Addr + Imm;
463-
return true;
464-
}
465-
466438
bool replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
467439
MCContext *Ctx) const override {
468440
assert((isCall(Inst) || isBranch(Inst)) && !isIndirectBranch(Inst) &&

0 commit comments

Comments
 (0)