[llvm] [BOLT] Update retained internal symbol addresses (PR #229407)
Adam Bzowski via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 7 04:11:03 PDT 2026
https://github.com/adam-bzowski-arm updated https://github.com/llvm/llvm-project/pull/229407
>From fb27bc4c22925d06e72f08c7884279aee82108e3 Mon Sep 17 00:00:00 2001
From: Adam Bzowski <Adam.Bzowski at arm.com>
Date: Mon, 5 Oct 2026 13:38:03 +0000
Subject: [PATCH 1/3] [BOLT] Update retained internal symbol addresses
Change-Id: I8403c0f6d91211767281ac5d037dc54bfa3f3f2a
---
bolt/include/bolt/Core/BinaryFunction.h | 29 ++++++++++--
bolt/lib/Core/BinaryFunction.cpp | 10 ++--
bolt/lib/Rewrite/RewriteInstance.cpp | 43 +++++++++++------
.../test/AArch64/retain-local-symbols-split.s | 46 +++++++++++++++++++
4 files changed, 106 insertions(+), 22 deletions(-)
create mode 100644 bolt/test/AArch64/retain-local-symbols-split.s
diff --git a/bolt/include/bolt/Core/BinaryFunction.h b/bolt/include/bolt/Core/BinaryFunction.h
index c41ad06027f64..723505b838b36 100644
--- a/bolt/include/bolt/Core/BinaryFunction.h
+++ b/bolt/include/bolt/Core/BinaryFunction.h
@@ -309,12 +309,21 @@ class BinaryFunction {
/// function is done.
SparseBitVector<> DebugScopeBoundaryOffsets;
+ /// Offsets of retained local symbols that are not represented as secondary
+ /// function entries. Populated before disassembly and cleared once
+ /// disassembly is done.
+ SparseBitVector<> RetainedLocalSymbolOffsets;
+
/// A set of local and global symbols corresponding to secondary entry points.
/// Each additional function entry point has a corresponding entry in the map.
/// The key is a local symbol corresponding to a basic block and the value
/// is a global symbol corresponding to an external entry point.
DenseMap<const MCSymbol *, MCSymbol *> SecondaryEntryPoints;
+ /// True if retained non-entry local symbols require precise input-to-output
+ /// address mappings after disassembly.
+ bool NeedsRetainedLocalSymbolAddressMap{false};
+
/// False if the function is too complex to reconstruct its control
/// flow graph.
/// In relocation mode we still disassemble and re-assemble such functions.
@@ -1408,7 +1417,8 @@ class BinaryFunction {
/// \p Inst located at function-relative \p Offset. Offsets are kept for
/// control-flow instructions (profile matching) and for instructions that
/// begin/end a DWARF lexical scope (needed to translate scope ranges
- /// precisely; see DebugScopeBoundaryOffsets).
+ /// precisely; see DebugScopeBoundaryOffsets), or have a retained local
+ /// symbol at their address.
bool keepOffsetForInstruction(const MCInst &Inst, uint32_t Offset);
/// Return the name of the section this function originated from.
@@ -1494,6 +1504,17 @@ class BinaryFunction {
/// Return true if the function has more than one entry point.
bool isMultiEntry() const { return !SecondaryEntryPoints.empty(); }
+ /// Return true if retained local symbols require precise address mappings.
+ bool needsRetainedLocalSymbolAddressMap() const {
+ return NeedsRetainedLocalSymbolAddressMap;
+ }
+
+ /// Record the function-relative \p Offset of a retained local symbol.
+ void addRetainedLocalSymbolOffset(uint32_t Offset) {
+ NeedsRetainedLocalSymbolAddressMap = true;
+ RetainedLocalSymbolOffsets.set(Offset);
+ }
+
/// Return true if the function might have a profile available externally,
/// but not yet populated into the function.
bool hasProfileAvailable() const { return HasProfileAvailable; }
@@ -2517,9 +2538,9 @@ class BinaryFunction {
bool requiresAddressMap() const;
/// Return true if this function needs an address-translation table after
- /// its code emission, or to update any metadata accurately (debug info,
- /// SDT probes). This is gated since it incurs extra cost for the linker
- /// to keep track of more addresses.
+ /// its code emission, or to update symbols and metadata accurately (local
+ /// symbols, debug info, SDT probes). This is gated since it incurs extra cost
+ /// for the linker to keep track of more addresses.
bool requiresPreciseAddressMap() const;
/// Adjust branch instructions to match the CFG.
diff --git a/bolt/lib/Core/BinaryFunction.cpp b/bolt/lib/Core/BinaryFunction.cpp
index 69eec01e098c1..080d760993c23 100644
--- a/bolt/lib/Core/BinaryFunction.cpp
+++ b/bolt/lib/Core/BinaryFunction.cpp
@@ -1305,7 +1305,8 @@ bool BinaryFunction::keepOffsetForInstruction(const MCInst &Inst,
if (MIB.isCall(Inst) || MIB.isBranch(Inst) || MIB.isReturn(Inst) ||
MIB.isPrefix(Inst) || MIB.isIndirectBranch(Inst))
return true;
- return isDebugScopeBoundaryOffset(Offset);
+ return isDebugScopeBoundaryOffset(Offset) ||
+ RetainedLocalSymbolOffsets.test(Offset);
}
Error BinaryFunction::disassemble() {
@@ -1529,8 +1530,9 @@ Error BinaryFunction::disassemble() {
addInstruction(Offset, std::move(Instruction));
}
- // Scope-boundary markers are only consulted while assigning offsets above.
+ // Input offsets are only consulted while assigning annotations above.
DebugScopeBoundaryOffsets.clear();
+ RetainedLocalSymbolOffsets.clear();
// Reset symbolizer for the disassembler.
BC.SymbolicDisAsm->setSymbolizer(nullptr);
@@ -3244,8 +3246,8 @@ bool BinaryFunction::finalizeCFIState() {
}
bool BinaryFunction::requiresPreciseAddressMap() const {
- return opts::UpdateDebugSections || opts::EnableBAT || hasSDTMarker() ||
- hasPseudoProbe();
+ return needsRetainedLocalSymbolAddressMap() || opts::UpdateDebugSections ||
+ opts::EnableBAT || hasSDTMarker() || hasPseudoProbe();
}
bool BinaryFunction::requiresAddressMap() const {
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index 018f8e465417f..d50e8eb23734f 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -394,6 +394,18 @@ MCPlusBuilder *createMCPlusBuilder(const Triple::ArchType Arch,
namespace {
+static bool isMarkerSymbol(const BinaryContext &BC, uint8_t ELFType,
+ uint64_t Size, StringRef Name) {
+ return BC.getMarkerType(ELFType, Size, Name) != MarkerSymType::NONE;
+}
+
+static bool isRetainedLocalSymbol(const BinaryContext &BC, uint8_t ELFType,
+ uint8_t Binding, uint64_t Size,
+ StringRef Name) {
+ return ELFType == ELF::STT_NOTYPE && Binding == ELF::STB_LOCAL &&
+ Size == 0 && !isMarkerSymbol(BC, ELFType, Size, Name);
+}
+
static Error reportDecompressionError(StringRef SectionName, Error E) {
return createStringError("failed to decompress section '" + SectionName +
"': " + toString(std::move(E)));
@@ -2373,12 +2385,20 @@ void RewriteInstance::adjustFunctionBoundaries(
if (!Function.isSymbolValidInScope(Symbol, SymbolSize))
break;
- // Skip basic block labels. This happens on RISC-V with linker relaxation
- // enabled because every branch needs a relocation and corresponding
- // symbol. We don't want to add such symbols as entry points.
+ // Do not add internal basic block labels as entry points. This happens on
+ // RISC-V with linker relaxation enabled because every branch needs a
+ // relocation and corresponding symbol. Record retained labels so their
+ // output addresses can be updated precisely.
const auto InternalSymbolPrefix = BC->AsmInfo->getInternalSymbolPrefix();
+ const StringRef SymbolName = cantFail(Symbol.getName());
if (!InternalSymbolPrefix.empty() &&
- cantFail(Symbol.getName()).starts_with(InternalSymbolPrefix)) {
+ SymbolName.starts_with(InternalSymbolPrefix)) {
+ const ELFSymbolRef ELFSymbol(Symbol);
+ if (isRetainedLocalSymbol(*BC, ELFSymbol.getELFType(),
+ ELFSymbol.getBinding(), SymbolSize,
+ SymbolName))
+ Function.addRetainedLocalSymbolOffset(SymbolAddress -
+ Function.getAddress());
++NextSymRefI;
continue;
}
@@ -5916,15 +5936,9 @@ void RewriteInstance::updateELFSymbolTable(
// it marks a secondary entry point.
// Also look up local NOTYPE symbols inside functions so we can
// update their addresses to reflect the output layout.
- // Skip AArch64/RISC-V marker symbols ($d, $x) inside functions —
- // BOLT generates its own via addExtraSymbols.
- auto IsMarkerSymbol = [&]() {
- return BC->getMarkerType(Symbol.getType(), Symbol.st_size,
- *SymbolName) != MarkerSymType::NONE;
- };
- const bool IsLocalLabel = Symbol.getType() == ELF::STT_NOTYPE &&
- Symbol.getBinding() == ELF::STB_LOCAL &&
- Symbol.st_size == 0 && !IsMarkerSymbol();
+ const bool IsLocalLabel =
+ isRetainedLocalSymbol(*BC, Symbol.getType(), Symbol.getBinding(),
+ Symbol.st_size, *SymbolName);
Function =
(Symbol.getType() == ELF::STT_FUNC || IsLocalLabel)
? BC->getBinaryFunctionContainingAddress(Symbol.st_value,
@@ -5995,7 +6009,8 @@ void RewriteInstance::updateELFSymbolTable(
// Drop AArch64/RISC-V marker symbols ($d, $x) inside functions —
// BOLT generates its own via addExtraSymbols.
- if (IsMarkerSymbol() &&
+ if (isMarkerSymbol(*BC, Symbol.getType(), Symbol.st_size,
+ *SymbolName) &&
BC->getBinaryFunctionContainingAddress(Symbol.st_value,
/*CheckPastEnd=*/false,
/*UseMaxSize=*/true)) {
diff --git a/bolt/test/AArch64/retain-local-symbols-split.s b/bolt/test/AArch64/retain-local-symbols-split.s
new file mode 100644
index 0000000000000..72a03e08c70fa
--- /dev/null
+++ b/bolt/test/AArch64/retain-local-symbols-split.s
@@ -0,0 +1,46 @@
+## Check that a local symbol in an outlined basic block is updated to its
+## address in the cold fragment.
+
+# REQUIRES: system-linux, asserts
+
+# RUN: llvm-mc -filetype=obj -triple aarch64-unknown-unknown \
+# RUN: -save-temp-labels %s -o %t.o
+# RUN: %clang %cflags %t.o -o %t.exe -nostdlib -Wl,-q,--discard-none
+# RUN: link_fdata %s %t.exe %t.fdata
+# RUN: llvm-bolt %t.exe -o %t.bolt --lite=0 --data %t.fdata \
+# RUN: --reorder-blocks=ext-tsp --split-functions --split-all-cold \
+# RUN: --print-cfg --print-only=_start > %t.out 2>&1
+# RUN: FileCheck %s --check-prefix=CFG < %t.out
+# RUN: llvm-nm -n %t.bolt | FileCheck %s --check-prefix=SYMBOL
+# RUN: llvm-objdump -d --disassemble-symbols=.L0 %t.bolt \
+# RUN: | FileCheck %s --check-prefix=CODE
+# RUN: llvm-bolt %t.exe -o %t.relax.bolt --lite=0 --data %t.fdata \
+# RUN: --reorder-blocks=ext-tsp --split-functions --split-all-cold --relax-exp
+# RUN: llvm-nm -n %t.relax.bolt | FileCheck %s --check-prefix=SYMBOL
+# RUN: llvm-objdump -d --disassemble-symbols=.L0 %t.relax.bolt \
+# RUN: | FileCheck %s --check-prefix=CODE
+
+# CFG: IsMultiEntry: 0
+# SYMBOL: t .L0
+# CODE: <.L0>:
+# CODE-NEXT: {{.*}} add x2, x2, #0x1
+
+ .text
+ .globl _start
+ .type _start, %function
+_start:
+# FDATA: 1 _start 0 1 _start 4 0 10
+.entry_start:
+ cbz x0, 1f
+ add x0, x0, #1
+ ret
+## Numeric labels are assembler-only and do not create retained ELF symbols.
+1:
+ sub x0, x0, #1
+ nop
+.L0:
+ add x2, x2, #1
+ ret
+ .size _start, .-_start
+
+ .reloc 0, R_AARCH64_NONE
>From b35371fb478491875d691912f4f5382d2cdaa80f Mon Sep 17 00:00:00 2001
From: Adam Bzowski <Adam.Bzowski at arm.com>
Date: Tue, 6 Oct 2026 16:51:52 +0000
Subject: [PATCH 2/3] [BOLT] Fix address map parsing for 32-bit targets
Change-Id: I4daa1130b5cac7825c77cba48cac495cf9bc0dc6
---
bolt/lib/Core/AddressMap.cpp | 28 +++++++++++++++++-----------
bolt/test/RISCV/address-map-rv32.s | 19 +++++++++++++++++++
2 files changed, 36 insertions(+), 11 deletions(-)
create mode 100644 bolt/test/RISCV/address-map-rv32.s
diff --git a/bolt/lib/Core/AddressMap.cpp b/bolt/lib/Core/AddressMap.cpp
index f061fea494394..eeae878a8aa1a 100644
--- a/bolt/lib/Core/AddressMap.cpp
+++ b/bolt/lib/Core/AddressMap.cpp
@@ -19,15 +19,18 @@ namespace bolt {
const char *const AddressMap::AddressSectionName = ".bolt.addr2addr_map";
const char *const AddressMap::LabelSectionName = ".bolt.label2addr_map";
+constexpr size_t MapValueSize = 8;
+constexpr size_t MapEntrySize = 2 * MapValueSize;
+
static void emitAddress(MCStreamer &Streamer, uint64_t InputAddress,
const MCSymbol *OutputLabel) {
- Streamer.emitIntValue(InputAddress, 8);
- Streamer.emitSymbolValue(OutputLabel, 8);
+ Streamer.emitIntValue(InputAddress, MapValueSize);
+ Streamer.emitSymbolValue(OutputLabel, MapValueSize);
}
static void emitLabel(MCStreamer &Streamer, const MCSymbol *OutputLabel) {
- Streamer.emitIntValue(reinterpret_cast<uint64_t>(OutputLabel), 8);
- Streamer.emitSymbolValue(OutputLabel, 8);
+ Streamer.emitIntValue(reinterpret_cast<uint64_t>(OutputLabel), MapValueSize);
+ Streamer.emitSymbolValue(OutputLabel, MapValueSize);
}
void AddressMap::emit(MCStreamer &Streamer, BinaryContext &BC) {
@@ -70,20 +73,22 @@ std::optional<AddressMap> AddressMap::parse(BinaryContext &BC) {
AddressMap Parsed;
- unsigned CodePointerSize = BC.AsmInfo->getCodePointerSize();
- const size_t EntrySize = 2 * CodePointerSize;
+ // Entries are emitted as pairs of 64-bit values. In the label map, the
+ // first value is an in-process MCSymbol pointer and is independent of the
+ // target code pointer size.
auto parseSection =
[&](BinarySection &Section,
function_ref<void(uint64_t, uint64_t)> InsertCallback) {
StringRef Buffer = Section.getOutputContents();
- assert(Buffer.size() % EntrySize == 0 && "Unexpected address map size");
+ assert(Buffer.size() % MapEntrySize == 0 &&
+ "Unexpected address map size");
DataExtractor DE(Buffer, BC.AsmInfo->isLittleEndian());
DataExtractor::Cursor Cursor(0);
while (Cursor && !DE.eof(Cursor)) {
- const uint64_t Input = DE.getUnsigned(Cursor, CodePointerSize);
- const uint64_t Output = DE.getUnsigned(Cursor, CodePointerSize);
+ const uint64_t Input = DE.getUnsigned(Cursor, MapValueSize);
+ const uint64_t Output = DE.getUnsigned(Cursor, MapValueSize);
InsertCallback(Input, Output);
}
@@ -93,7 +98,7 @@ std::optional<AddressMap> AddressMap::parse(BinaryContext &BC) {
if (AddressMapSection) {
Parsed.Address2AddressMap.reserve(AddressMapSection->getOutputSize() /
- EntrySize);
+ MapEntrySize);
parseSection(*AddressMapSection, [&](uint64_t Input, uint64_t Output) {
if (!Parsed.Address2AddressMap.count(Input))
Parsed.Address2AddressMap.insert({Input, Output});
@@ -101,7 +106,8 @@ std::optional<AddressMap> AddressMap::parse(BinaryContext &BC) {
}
if (LabelMapSection) {
- Parsed.Label2AddrMap.reserve(LabelMapSection->getOutputSize() / EntrySize);
+ Parsed.Label2AddrMap.reserve(LabelMapSection->getOutputSize() /
+ MapEntrySize);
parseSection(*LabelMapSection, [&](uint64_t Input, uint64_t Output) {
assert(!Parsed.Label2AddrMap.count(
reinterpret_cast<const MCSymbol *>(Input)) &&
diff --git a/bolt/test/RISCV/address-map-rv32.s b/bolt/test/RISCV/address-map-rv32.s
new file mode 100644
index 0000000000000..86e89bed52dc5
--- /dev/null
+++ b/bolt/test/RISCV/address-map-rv32.s
@@ -0,0 +1,19 @@
+## Check that BOLT parses its internal address map correctly for a 32-bit
+## target. Address-map entries contain 64-bit values even when the target code
+## pointer size is 32 bits.
+
+# REQUIRES: asserts
+
+# RUN: llvm-mc -triple=riscv32 -mattr=+c -filetype=obj %s -o %t.o
+# RUN: ld.lld -q %t.o -o %t
+# RUN: llvm-bolt --enable-bat %t -o %t.bolt
+
+ .text
+ .globl _start
+ .type _start, @function
+ .p2align 1
+_start:
+ nop
+1:
+ j 1b
+ .size _start, .-_start
>From d917c896fcd372eadf0caac7def73e2e284315bf Mon Sep 17 00:00:00 2001
From: Adam Bzowski <Adam.Bzowski at arm.com>
Date: Wed, 7 Oct 2026 10:18:49 +0000
Subject: [PATCH 3/3] [BOLT] Update RISC-V tests for retained local symbols
Change-Id: Ia754e6570244fe14d1424af5c1f6968f3b26b71e
---
bolt/lib/Rewrite/RewriteInstance.cpp | 4 ++--
bolt/test/RISCV/cond-tail-call.s | 3 ++-
bolt/test/RISCV/fix-block-count-multiple.s | 4 ++--
bolt/test/RISCV/reloc-bb-split-rv32.s | 4 ++--
bolt/test/RISCV/reloc-bb-split.s | 4 ++--
bolt/test/RISCV/reloc-got.s | 6 +++---
bolt/test/RISCV/reloc-pcrel-rv32.s | 4 ++--
bolt/test/RISCV/reloc-pcrel.s | 4 ++--
bolt/test/RISCV/reorder-blocks-reverse.s | 19 ++++++++++---------
9 files changed, 27 insertions(+), 25 deletions(-)
diff --git a/bolt/lib/Rewrite/RewriteInstance.cpp b/bolt/lib/Rewrite/RewriteInstance.cpp
index d50e8eb23734f..2b093668a5302 100644
--- a/bolt/lib/Rewrite/RewriteInstance.cpp
+++ b/bolt/lib/Rewrite/RewriteInstance.cpp
@@ -402,8 +402,8 @@ static bool isMarkerSymbol(const BinaryContext &BC, uint8_t ELFType,
static bool isRetainedLocalSymbol(const BinaryContext &BC, uint8_t ELFType,
uint8_t Binding, uint64_t Size,
StringRef Name) {
- return ELFType == ELF::STT_NOTYPE && Binding == ELF::STB_LOCAL &&
- Size == 0 && !isMarkerSymbol(BC, ELFType, Size, Name);
+ return ELFType == ELF::STT_NOTYPE && Binding == ELF::STB_LOCAL && Size == 0 &&
+ !isMarkerSymbol(BC, ELFType, Size, Name);
}
static Error reportDecompressionError(StringRef SectionName, Error E) {
diff --git a/bolt/test/RISCV/cond-tail-call.s b/bolt/test/RISCV/cond-tail-call.s
index 7034617431b5f..93d6e3b42270d 100644
--- a/bolt/test/RISCV/cond-tail-call.s
+++ b/bolt/test/RISCV/cond-tail-call.s
@@ -1,6 +1,6 @@
// RUN: %clang %cflags64 -o %t %s
// RUN: llvm-bolt -o %t.bolt %t
-// RUN: llvm-objdump -d --disassemble-symbols=f %t.bolt | FileCheck %s
+// RUN: llvm-objdump -d --disassemble-symbols=f,.Lcont %t.bolt | FileCheck %s
.text
@@ -24,6 +24,7 @@ f:
/// which drops both the condition and the fall-through path.
/// NOTE: This seems not reasonable in general, however this might created when
/// program has __builtin_unreachable or undefined behavior.
+// CHECK: <.Lcont>:
// CHECK-NEXT: j {{.*}} <g>
beqz a0, .Lend
// CHECK-NEXT: li a0, 0x1
diff --git a/bolt/test/RISCV/fix-block-count-multiple.s b/bolt/test/RISCV/fix-block-count-multiple.s
index 57c9d6689fd52..f0723f64a5512 100644
--- a/bolt/test/RISCV/fix-block-count-multiple.s
+++ b/bolt/test/RISCV/fix-block-count-multiple.s
@@ -29,7 +29,7 @@
# INDIRECT_HIGHER: jalr {{.*}}# CallProfile: 40 (0 misses) :
# INDIRECT_HIGHER-DAG: { foo: 10 (0 misses) }
# INDIRECT_HIGHER-DAG: { bar: 30 (0 misses) }
-# INDIRECT_HIGHER: jal {{.*}}foo # Count: 20
+# INDIRECT_HIGHER: jal {{.*}}foo # Offset: 32 # Count: 20
# FDATA_DIRECT_CALL_LARGER: 0 [unknown] 0 1 main 0 0 0
# FDATA_DIRECT_CALL_LARGER: 1 main #firstIndirectLabel# 1 foo 0 0 10
@@ -47,7 +47,7 @@
# DIRECT_HIGHER: {{.*}}# CallProfile: 60 (0 misses) :
# DIRECT_HIGHER-DAG: { bar: 20 (0 misses) }
# DIRECT_HIGHER-DAG: { foo: 40 (0 misses) }
-# DIRECT_HIGHER: jal {{.*}}foo # Count: 100
+# DIRECT_HIGHER: jal {{.*}}foo # Offset: 32 # Count: 100
.type main, at function
.type foo, at function
diff --git a/bolt/test/RISCV/reloc-bb-split-rv32.s b/bolt/test/RISCV/reloc-bb-split-rv32.s
index a434f5c71bd63..7ada9f8eaffdf 100644
--- a/bolt/test/RISCV/reloc-bb-split-rv32.s
+++ b/bolt/test/RISCV/reloc-bb-split-rv32.s
@@ -21,7 +21,7 @@ _start:
// CHECK-LABEL: {{^}}.LBB00
// CHECK: nop
// CHECK: {{^}}[[BRANCH_LABEL:.Ltmp[0-9]+]]
-// CHECK: auipc t0, %pcrel_hi(d) # Label: [[HI_LABEL:.Ltmp[0-9]+]]
+// CHECK: auipc t0, %pcrel_hi(d) # Offset: 2 # Label: [[HI_LABEL:.Ltmp[0-9]+]]
// CHECK-NEXT: lw t0, %pcrel_lo([[HI_LABEL]])(t0)
// CHECK-NEXT: j [[BRANCH_LABEL]]
nop
@@ -34,7 +34,7 @@ _start:
/// start there.
// CHECK-LABEL: {{^}}.LFT0
// CHECK: nop
-// CHECK: auipc t0, %pcrel_hi(d) # Label: [[SECOND_HI:.Ltmp[0-9]+]]
+// CHECK: auipc t0, %pcrel_hi(d) # Offset: 14 # Label: [[SECOND_HI:.Ltmp[0-9]+]]
// CHECK-NEXT: lw t0, %pcrel_lo([[SECOND_HI]])(t0)
// CHECK-NEXT: ret
nop
diff --git a/bolt/test/RISCV/reloc-bb-split.s b/bolt/test/RISCV/reloc-bb-split.s
index f862dd96fd79a..ec3013bdc50f0 100644
--- a/bolt/test/RISCV/reloc-bb-split.s
+++ b/bolt/test/RISCV/reloc-bb-split.s
@@ -18,7 +18,7 @@ _start:
// CHECK-LABEL: {{^}}.LBB00
// CHECK: nop
// CHECK: {{^}}[[BRANCH_LABEL:.Ltmp[0-9]+]]
-// CHECK: auipc t0, %pcrel_hi(d) # Label: [[HI_LABEL:.Ltmp[0-9]+]]
+// CHECK: auipc t0, %pcrel_hi(d) # Offset: 2 # Label: [[HI_LABEL:.Ltmp[0-9]+]]
// CHECK-NEXT: ld t0, %pcrel_lo([[HI_LABEL]])(t0)
// CHECK-NEXT: j [[BRANCH_LABEL]]
nop
@@ -31,7 +31,7 @@ _start:
/// start there.
// CHECK-LABEL: {{^}}.LFT0
// CHECK: nop
-// CHECK-NEXT: auipc t0, %pcrel_hi(d) # Label: [[SECOND_HI:.Ltmp[0-9]+]]
+// CHECK-NEXT: auipc t0, %pcrel_hi(d) # Offset: 14 # Label: [[SECOND_HI:.Ltmp[0-9]+]]
// CHECK-NEXT: ld t0, %pcrel_lo([[SECOND_HI]])(t0)
// CHECK-NEXT: ret
nop
diff --git a/bolt/test/RISCV/reloc-got.s b/bolt/test/RISCV/reloc-got.s
index 905d8451a6365..42403f6cd2310 100644
--- a/bolt/test/RISCV/reloc-got.s
+++ b/bolt/test/RISCV/reloc-got.s
@@ -17,7 +17,7 @@ _start:
nop // Here to not make the _start and the %pcrel_lo label coincide
/// The load follows the AUIPC, so BOLT resolves the right GOT entry.
-// CHECK: auipc t0, %pcrel_hi(__BOLT_got_zero+[[GOT:[0-9]+]]) # Label: [[HI:\.Ltmp[0-9]+]]
+// CHECK: auipc t0, %pcrel_hi(__BOLT_got_zero+[[GOT:[0-9]+]]) # Offset: 2 # Label: [[HI:\.Ltmp[0-9]+]]
// CHECK-NEXT: ld t0, %pcrel_lo([[HI]])(t0)
1:
auipc t0, %got_pcrel_hi(d)
@@ -25,7 +25,7 @@ _start:
/// An unrelated instruction can sit between the AUIPC and its load. The
/// symbolizer locates the low relocation through its reference to the AUIPC.
-// CHECK: auipc t1, %pcrel_hi(__BOLT_got_zero+[[GOT]]) # Label: [[HI2:\.Ltmp[0-9]+]]
+// CHECK: auipc t1, %pcrel_hi(__BOLT_got_zero+[[GOT]]) # Offset: 10 # Label: [[HI2:\.Ltmp[0-9]+]]
// CHECK-NEXT: addi t2, t2, 0x7ff
// CHECK-NEXT: ld t1, %pcrel_lo([[HI2]])(t1)
2:
@@ -42,7 +42,7 @@ _start:
nop
/// The low relocation can also precede the AUIPC in output basic-block order.
// CHECK: nop
-// CHECK-NEXT: auipc t1, %pcrel_hi(__BOLT_got_zero+[[GOT]]) # Label: [[HI3]]
+// CHECK-NEXT: auipc t1, %pcrel_hi(__BOLT_got_zero+[[GOT]]) # Offset: 32 # Label: [[HI3]]
// CHECK-NEXT: j
3:
auipc t1, %got_pcrel_hi(d)
diff --git a/bolt/test/RISCV/reloc-pcrel-rv32.s b/bolt/test/RISCV/reloc-pcrel-rv32.s
index f78a9d75bf796..dda09a0a1e80a 100644
--- a/bolt/test/RISCV/reloc-pcrel-rv32.s
+++ b/bolt/test/RISCV/reloc-pcrel-rv32.s
@@ -18,10 +18,10 @@ d:
// CHECK: Binary Function "_start" after building cfg {
_start:
nop // Here to not make the _start and .Ltmp0 symbols coincide
-// CHECK: auipc t0, %pcrel_hi(d) # Label: [[HI_LABEL:.Ltmp[0-9]+]]
+// CHECK: auipc t0, %pcrel_hi(d) # Offset: 2 # Label: [[HI_LABEL:.Ltmp[0-9]+]]
// CHECK-NEXT: lw t0, %pcrel_lo([[HI_LABEL]])(t0)
lw t0, d
-// CHECK: auipc t1, %pcrel_hi(d) # Label: [[SECOND_HI:.Ltmp[0-9]+]]
+// CHECK: auipc t1, %pcrel_hi(d) # Offset: 10 # Label: [[SECOND_HI:.Ltmp[0-9]+]]
// CHECK-NEXT: sw t0, %pcrel_lo([[SECOND_HI]])(t1)
sw t0, d, t1
ret
diff --git a/bolt/test/RISCV/reloc-pcrel.s b/bolt/test/RISCV/reloc-pcrel.s
index 12324b4e112c9..6dd8b50fbfd75 100644
--- a/bolt/test/RISCV/reloc-pcrel.s
+++ b/bolt/test/RISCV/reloc-pcrel.s
@@ -15,10 +15,10 @@ d:
// CHECK: Binary Function "_start" after building cfg {
_start:
nop // Here to not make the _start and .Ltmp0 symbols coincide
-// CHECK: auipc t0, %pcrel_hi(d) # Label: .Ltmp0
+// CHECK: auipc t0, %pcrel_hi(d) # Offset: 2 # Label: .Ltmp0
// CHECK-NEXT: ld t0, %pcrel_lo(.Ltmp0)(t0)
ld t0, d
-// CHECK-NEXT: auipc t1, %pcrel_hi(d) # Label: .Ltmp1
+// CHECK-NEXT: auipc t1, %pcrel_hi(d) # Offset: 10 # Label: .Ltmp1
// CHECK-NEXT: sd t0, %pcrel_lo(.Ltmp1)(t1)
sd t0, d, t1
ret
diff --git a/bolt/test/RISCV/reorder-blocks-reverse.s b/bolt/test/RISCV/reorder-blocks-reverse.s
index c97409f3cc604..a44fe7762b3ca 100644
--- a/bolt/test/RISCV/reorder-blocks-reverse.s
+++ b/bolt/test/RISCV/reorder-blocks-reverse.s
@@ -25,12 +25,13 @@ _start:
.size _start,.-_start
// CHECK: {{.*}}00 <_start>:
-// CHECK-NEXT: {{.*}}00: beq t0, t1, {{.*}} <_start+0x10>
-// CHECK-NEXT: {{.*}}04: j {{.*}} <_start+0x16>
-// CHECK-NEXT: {{.*}}08: ret
-// CHECK-NEXT: {{.*}}0a: li a0, 0x6
-// CHECK-NEXT: {{.*}}0c: j {{.*}} <_start+0x8>
-// CHECK-NEXT: {{.*}}10: li a0, 0x5
-// CHECK-NEXT: {{.*}}12: j {{.*}} <_start+0x8>
-// CHECK-NEXT: {{.*}}16: beq t0, t2, {{.*}} <_start+0xa>
-// CHECK-NEXT: {{.*}}1a: j {{.*}} <_start+0x10>
+// CHECK: {{.*}}00: beq t0, t1, {{.*}} <[[L0:.Ltmp[0-9]+]]>
+// CHECK: {{.*}}04: j {{.*}} <[[L0]]+0x6>
+// CHECK: {{.*}}08: ret
+// CHECK: {{.*}}0a: li a0, 0x6
+// CHECK: {{.*}}0c: j {{.*}}08 <{{(\.Ltmp[0-9]+|_start\+0x8)}}>
+// CHECK: {{.*}}10 <[[L0]]>:
+// CHECK: {{.*}}10: li a0, 0x5
+// CHECK: {{.*}}12: j {{.*}}08 <{{(\.Ltmp[0-9]+|_start\+0x8)}}>
+// CHECK: {{.*}}16: beq t0, t2, {{.*}}0a <{{(\.Ltmp[0-9]+|_start\+0xa)}}>
+// CHECK: {{.*}}1a: j {{.*}} <[[L0]]>
More information about the llvm-commits
mailing list