Skip to content

Commit bcb1ec8

Browse files
committed
[BOLT][NFC] Infailable fns return void
1 parent 58c7785 commit bcb1ec8

File tree

5 files changed

+12
-25
lines changed

5 files changed

+12
-25
lines changed

bolt/include/bolt/Core/MCPlusBuilder.h

+2-8
Original file line numberDiff line numberDiff line change
@@ -1706,12 +1706,9 @@ class MCPlusBuilder {
17061706
}
17071707

17081708
/// Reverses the branch condition in Inst and update its taken target to TBB.
1709-
///
1710-
/// Returns true on success.
1711-
virtual bool reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
1709+
virtual void reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
17121710
MCContext *Ctx) const {
17131711
llvm_unreachable("not implemented");
1714-
return false;
17151712
}
17161713

17171714
virtual bool replaceBranchCondition(MCInst &Inst, const MCSymbol *TBB,
@@ -1751,12 +1748,9 @@ class MCPlusBuilder {
17511748
}
17521749

17531750
/// Sets the taken target of the branch instruction to Target.
1754-
///
1755-
/// Returns true on success.
1756-
virtual bool replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
1751+
virtual void replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
17571752
MCContext *Ctx) const {
17581753
llvm_unreachable("not implemented");
1759-
return false;
17601754
}
17611755

17621756
/// Extract a symbol and an addend out of the fixup value expression.

bolt/lib/Passes/VeneerElimination.cpp

+2-5
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,8 @@ Error VeneerElimination::runOnFunctions(BinaryContext &BC) {
7777
continue;
7878

7979
VeneerCallers++;
80-
if (!BC.MIB->replaceBranchTarget(
81-
Instr, VeneerDestinations[TargetSymbol], BC.Ctx.get())) {
82-
return createFatalBOLTError(
83-
"BOLT-ERROR: updating veneer call destination failed\n");
84-
}
80+
BC.MIB->replaceBranchTarget(Instr, VeneerDestinations[TargetSymbol],
81+
BC.Ctx.get());
8582
}
8683
}
8784
}

bolt/lib/Target/AArch64/AArch64MCPlusBuilder.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -616,7 +616,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
616616
return getTargetAddend(Op.getExpr());
617617
}
618618

619-
bool replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
619+
void replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
620620
MCContext *Ctx) const override {
621621
assert((isCall(Inst) || isBranch(Inst)) && !isIndirectBranch(Inst) &&
622622
"Invalid instruction");
@@ -638,7 +638,6 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
638638

639639
*OI = MCOperand::createExpr(
640640
MCSymbolRefExpr::create(TBB, MCSymbolRefExpr::VK_None, *Ctx));
641-
return true;
642641
}
643642

644643
/// Matches indirect branch patterns in AArch64 related to a jump table (JT),
@@ -969,7 +968,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
969968
}
970969
}
971970

972-
bool reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
971+
void reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
973972
MCContext *Ctx) const override {
974973
if (isTB(Inst) || isCB(Inst)) {
975974
Inst.setOpcode(getInvertedBranchOpcode(Inst.getOpcode()));
@@ -984,7 +983,7 @@ class AArch64MCPlusBuilder : public MCPlusBuilder {
984983
LLVM_DEBUG(Inst.dump());
985984
llvm_unreachable("Unrecognized branch instruction");
986985
}
987-
return replaceBranchTarget(Inst, TBB, Ctx);
986+
replaceBranchTarget(Inst, TBB, Ctx);
988987
}
989988

990989
int getPCRelEncodingSize(const MCInst &Inst) const override {

bolt/lib/Target/RISCV/RISCVMCPlusBuilder.cpp

+3-4
Original file line numberDiff line numberDiff line change
@@ -151,14 +151,14 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
151151
}
152152
}
153153

154-
bool reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
154+
void reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
155155
MCContext *Ctx) const override {
156156
auto Opcode = getInvertedBranchOpcode(Inst.getOpcode());
157157
Inst.setOpcode(Opcode);
158-
return replaceBranchTarget(Inst, TBB, Ctx);
158+
replaceBranchTarget(Inst, TBB, Ctx);
159159
}
160160

161-
bool replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
161+
void replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
162162
MCContext *Ctx) const override {
163163
assert((isCall(Inst) || isBranch(Inst)) && !isIndirectBranch(Inst) &&
164164
"Invalid instruction");
@@ -170,7 +170,6 @@ class RISCVMCPlusBuilder : public MCPlusBuilder {
170170

171171
Inst.getOperand(SymOpIndex) = MCOperand::createExpr(
172172
MCSymbolRefExpr::create(TBB, MCSymbolRefExpr::VK_None, *Ctx));
173-
return true;
174173
}
175174

176175
IndirectBranchType analyzeIndirectBranch(

bolt/lib/Target/X86/X86MCPlusBuilder.cpp

+2-4
Original file line numberDiff line numberDiff line change
@@ -2782,14 +2782,13 @@ class X86MCPlusBuilder : public MCPlusBuilder {
27822782
Inst.addOperand(MCOperand::createImm(CC));
27832783
}
27842784

2785-
bool reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
2785+
void reverseBranchCondition(MCInst &Inst, const MCSymbol *TBB,
27862786
MCContext *Ctx) const override {
27872787
unsigned InvCC = getInvertedCondCode(getCondCode(Inst));
27882788
assert(InvCC != X86::COND_INVALID && "invalid branch instruction");
27892789
Inst.getOperand(Info->get(Inst.getOpcode()).NumOperands - 1).setImm(InvCC);
27902790
Inst.getOperand(0) = MCOperand::createExpr(
27912791
MCSymbolRefExpr::create(TBB, MCSymbolRefExpr::VK_None, *Ctx));
2792-
return true;
27932792
}
27942793

27952794
bool replaceBranchCondition(MCInst &Inst, const MCSymbol *TBB, MCContext *Ctx,
@@ -2832,13 +2831,12 @@ class X86MCPlusBuilder : public MCPlusBuilder {
28322831
}
28332832
}
28342833

2835-
bool replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
2834+
void replaceBranchTarget(MCInst &Inst, const MCSymbol *TBB,
28362835
MCContext *Ctx) const override {
28372836
assert((isCall(Inst) || isBranch(Inst)) && !isIndirectBranch(Inst) &&
28382837
"Invalid instruction");
28392838
Inst.getOperand(0) = MCOperand::createExpr(
28402839
MCSymbolRefExpr::create(TBB, MCSymbolRefExpr::VK_None, *Ctx));
2841-
return true;
28422840
}
28432841

28442842
MCPhysReg getX86R11() const override { return X86::R11; }

0 commit comments

Comments
 (0)