Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 16 additions & 4 deletions bolt/lib/Core/BinaryFunction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1783,10 +1783,22 @@ bool BinaryFunction::scanExternalRefs() {
// On AArch64, we use instruction patches for fixing references. We make an
// exception for branch instructions since they require optional
// relocations.
if (BC.isAArch64() && !BranchTargetSymbol) {
LLVM_DEBUG(BC.printInstruction(dbgs(), Instruction, AbsoluteInstrAddr));
InstructionPatches.push_back({AbsoluteInstrAddr, Instruction});
continue;
if (BC.isAArch64()) {
if (!BranchTargetSymbol) {
LLVM_DEBUG(BC.printInstruction(dbgs(), Instruction, AbsoluteInstrAddr));
InstructionPatches.push_back({AbsoluteInstrAddr, Instruction});
continue;
}

// Conditional tail calls require new relocation types that are currently
// not supported. https://github.com/llvm/llvm-project/issues/138264
if (BC.MIB->isConditionalBranch(Instruction)) {
if (BinaryFunction *TargetBF =
BC.getFunctionForSymbol(BranchTargetSymbol)) {
TargetBF->setNeedsPatch(true);
continue;
}
}
}

// Emit the instruction using temp emitter and generate relocations.
Expand Down
9 changes: 9 additions & 0 deletions bolt/test/AArch64/lite-mode.s
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,15 @@ cold_function:
# CHECK-INPUT-NEXT: b {{.*}} <_start>
# CHECK-NEXT: b {{.*}} <_start.org.0>

## Quick test for conditional tail calls. A proper test is being added in:
## https://github.com/llvm/llvm-project/pull/139565
## For now check that llvm-bolt doesn't choke on CTCs.
.ifndef COMPACT
b.eq _start
cbz x0, _start
tbz x0, 42, _start
.endif

.cfi_endproc
.size cold_function, .-cold_function

Expand Down
Loading