Skip to content

Commit ab1c1d4

Browse files
committed
fixup! [BOLT][AArch64] Add support for long absolute LLD thunks
1 parent 5cf5322 commit ab1c1d4

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

bolt/include/bolt/Core/MCPlusBuilder.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1536,6 +1536,9 @@ class MCPlusBuilder {
15361536
llvm_unreachable("not implemented");
15371537
}
15381538

1539+
/// Match function \p BF to a long veneer for absolute code. Return true if
1540+
/// the match was successful and populate \p TargetAddress with an address of
1541+
/// the function veneer jumps to.
15391542
virtual bool matchAbsLongVeneer(const BinaryFunction &BF,
15401543
uint64_t &TargetAddress) const {
15411544
llvm_unreachable("not implemented");

bolt/lib/Passes/VeneerElimination.cpp

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,6 @@ Error VeneerElimination::runOnFunctions(BinaryContext &BC) {
3737
if (!opts::EliminateVeneers || !BC.isAArch64())
3838
return Error::success();
3939

40-
std::map<uint64_t, BinaryFunction> &BFs = BC.getBinaryFunctions();
4140
std::unordered_map<const MCSymbol *, const MCSymbol *> VeneerDestinations;
4241
uint64_t NumEliminatedVeneers = 0;
4342
for (BinaryFunction &BF : llvm::make_second_range(BC.getBinaryFunctions())) {
@@ -47,17 +46,16 @@ Error VeneerElimination::runOnFunctions(BinaryContext &BC) {
4746
if (BF.isIgnored())
4847
continue;
4948

50-
MCInst &FirstInstruction = *(BF.begin()->begin());
5149
const MCSymbol *VeneerTargetSymbol = 0;
5250
uint64_t TargetAddress;
5351
if (BC.MIB->matchAbsLongVeneer(BF, TargetAddress)) {
5452
if (BinaryFunction *TargetBF =
5553
BC.getBinaryFunctionAtAddress(TargetAddress))
5654
VeneerTargetSymbol = TargetBF->getSymbol();
5755
} else {
58-
if (!BC.MIB->hasAnnotation(FirstInstruction, "AArch64Veneer"))
59-
continue;
60-
VeneerTargetSymbol = BC.MIB->getTargetSymbol(FirstInstruction, 1);
56+
MCInst &FirstInstruction = *(BF.begin()->begin());
57+
if (BC.MIB->hasAnnotation(FirstInstruction, "AArch64Veneer"))
58+
VeneerTargetSymbol = BC.MIB->getTargetSymbol(FirstInstruction, 1);
6159
}
6260

6361
if (!VeneerTargetSymbol)
@@ -84,9 +82,8 @@ Error VeneerElimination::runOnFunctions(BinaryContext &BC) {
8482
}
8583

8684
uint64_t VeneerCallers = 0;
87-
for (auto &It : BFs) {
88-
BinaryFunction &Function = It.second;
89-
for (BinaryBasicBlock &BB : Function) {
85+
for (BinaryFunction &BF : llvm::make_second_range(BC.getBinaryFunctions())) {
86+
for (BinaryBasicBlock &BB : BF) {
9087
for (MCInst &Instr : BB) {
9188
if (!BC.MIB->isCall(Instr) || BC.MIB->isIndirectCall(Instr))
9289
continue;

0 commit comments

Comments
 (0)