[llvm] 7088910 - MCAsmStreamer: Print relocation type number if applicable
Fangrui Song via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 17 21:25:57 PDT 2025
Author: Fangrui Song
Date: 2025-04-17T21:25:51-07:00
New Revision: 7088910b9f74d49a7e0a107a2261be90c1c8bd1b
URL: https://github.com/llvm/llvm-project/commit/7088910b9f74d49a7e0a107a2261be90c1c8bd1b
DIFF: https://github.com/llvm/llvm-project/commit/7088910b9f74d49a7e0a107a2261be90c1c8bd1b.diff
LOG: MCAsmStreamer: Print relocation type number if applicable
The fixup output is a debug aid and should not be used to test
target-specific relocation generation implementation. The llvm-mc
-filetype=obj output is what truly matters.
Added:
Modified:
llvm/lib/MC/MCAsmStreamer.cpp
llvm/test/MC/AArch64/tls-relocs.s
Removed:
################################################################################
diff --git a/llvm/lib/MC/MCAsmStreamer.cpp b/llvm/lib/MC/MCAsmStreamer.cpp
index 9fb79d676f2c7..ff5f13c54b17b 100644
--- a/llvm/lib/MC/MCAsmStreamer.cpp
+++ b/llvm/lib/MC/MCAsmStreamer.cpp
@@ -2399,12 +2399,16 @@ void MCAsmStreamer::AddEncodingComment(const MCInst &Inst,
for (unsigned i = 0, e = Fixups.size(); i != e; ++i) {
MCFixup &F = Fixups[i];
- const MCFixupKindInfo &Info =
- getAssembler().getBackend().getFixupKindInfo(F.getKind());
OS << " fixup " << char('A' + i) << " - "
<< "offset: " << F.getOffset() << ", value: ";
F.getValue()->print(OS, MAI);
- OS << ", kind: " << Info.Name << "\n";
+ auto Kind = F.getKind();
+ if (FirstRelocationKind <= Kind)
+ OS << ", relocation type: " << (Kind - FirstRelocationKind);
+ else
+ OS << ", kind: "
+ << getAssembler().getBackend().getFixupKindInfo(Kind).Name;
+ OS << '\n';
}
}
diff --git a/llvm/test/MC/AArch64/tls-relocs.s b/llvm/test/MC/AArch64/tls-relocs.s
index 3cdad8e5ca504..619011e8e3cd6 100644
--- a/llvm/test/MC/AArch64/tls-relocs.s
+++ b/llvm/test/MC/AArch64/tls-relocs.s
@@ -389,7 +389,7 @@
// CHECK: add x5, x4, :tlsdesc_lo12:var // encoding: [0x85,0bAAAAAA00,0b00AAAAAA,0x91]
// CHECK: // fixup A - offset: 0, value: :tlsdesc_lo12:var, kind: fixup_aarch64_add_imm12
// CHECK: .tlsdesccall var // encoding: []
-// CHECK-NEXT: // fixup A - offset: 0, value: var, kind: FK_NONE
+// CHECK-NEXT: // fixup A - offset: 0, value: var, relocation type: 569
// CHECK: blr x3 // encoding: [0x60,0x00,0x3f,0xd6]
// CHECK-ELF-NEXT: 0x104 R_AARCH64_TLSDESC_ADR_PAGE21 [[VARSYM]]
More information about the llvm-commits
mailing list