Skip to content

Commit 6b3ba87

Browse files
committed
Address review feedback
1 parent 241ea1b commit 6b3ba87

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -614,10 +614,7 @@ bool RISCVAsmBackend::evaluateTargetFixup(const MCFixup &Fixup,
614614

615615
void RISCVAsmBackend::maybeAddVendorReloc(const MCFragment &F,
616616
const MCFixup &Fixup) {
617-
MCContext &Ctx = Asm->getContext();
618-
619617
StringRef VendorIdentifier;
620-
621618
switch (Fixup.getTargetKind()) {
622619
default:
623620
// No Vendor Relocation Required.
@@ -632,6 +629,7 @@ void RISCVAsmBackend::maybeAddVendorReloc(const MCFragment &F,
632629

633630
// Create a local symbol for the vendor relocation to reference. It's fine if
634631
// the symbol has the same name as an existing symbol.
632+
MCContext &Ctx = Asm->getContext();
635633
MCSymbol *VendorSymbol = Ctx.createLocalSymbol(VendorIdentifier);
636634
auto [It, Inserted] =
637635
VendorSymbols.try_emplace(VendorIdentifier, VendorSymbol);
@@ -645,12 +643,10 @@ void RISCVAsmBackend::maybeAddVendorReloc(const MCFragment &F,
645643
VendorSymbol = It->getValue();
646644
}
647645

648-
const MCExpr *VendorExpr = MCSymbolRefExpr::create(VendorSymbol, Ctx);
649646
MCFixup VendorFixup =
650-
MCFixup::create(Fixup.getOffset(), VendorExpr, ELF::R_RISCV_VENDOR);
651-
// Explicitly create MCValue rather than using
652-
// `VendorExpr->evaluateAsRelocatable` so that the absolute symbol is not
653-
// evaluated to constant 0.
647+
MCFixup::create(Fixup.getOffset(), nullptr, ELF::R_RISCV_VENDOR);
648+
// Explicitly create MCValue rather than using an MCExpr and evaluating it so
649+
// that the absolute vendor symbol is not evaluated to constant 0.
654650
MCValue VendorTarget = MCValue::get(VendorSymbol);
655651
uint64_t VendorValue;
656652
Asm->getWriter().recordRelocation(F, VendorFixup, VendorTarget, VendorValue);

llvm/test/MC/RISCV/vendor-symbol.s

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
## relocations do not interfere with symbols with identical names that
99
## are written in assembly.
1010

11-
.option exact
11+
.option exact
1212

1313
qc.e.bgeui s0, 20, QUALCOMM
1414

@@ -28,5 +28,8 @@ QUALCOMM:
2828

2929

3030
# CHECK-LABEL: Symbol table '.symtab'
31+
# CHECK-NOT: QUALCOMM
3132
# CHECK: 00000000 0 NOTYPE LOCAL DEFAULT ABS QUALCOMM
33+
# CHECK-NOT: QUALCOMM
3234
# CHECK: 00000006 0 NOTYPE GLOBAL DEFAULT 2 QUALCOMM
35+
# CHECK-NOT: QUALCOMM

0 commit comments

Comments
 (0)