[PATCH] D58943: [RISCV][MC] Find matching pcrel_hi fixup in more cases.
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Mar 12 11:14:20 PDT 2019
This revision was automatically updated to reflect the committed changes.
Closed by commit rL355946: [RISCV][MC] Find matching pcrel_hi fixup in more cases. (authored by efriedma, committed by ).
Changed prior to commit:
https://reviews.llvm.org/D58943?vs=189247&id=190298#toc
Repository:
rL LLVM
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D58943/new/
https://reviews.llvm.org/D58943
Files:
llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp
llvm/trunk/test/MC/RISCV/option-mix.s
Index: llvm/trunk/test/MC/RISCV/option-mix.s
===================================================================
--- llvm/trunk/test/MC/RISCV/option-mix.s
+++ llvm/trunk/test/MC/RISCV/option-mix.s
@@ -0,0 +1,51 @@
+# RUN: llvm-mc %s -triple=riscv32 | FileCheck -check-prefix=ASM %s
+# RUN: llvm-mc %s -triple=riscv64 | FileCheck -check-prefix=ASM %s
+# RUN: llvm-mc -filetype=obj -triple riscv32 < %s \
+# RUN: | llvm-objdump -d -riscv-no-aliases - | FileCheck -check-prefix=DISASM %s
+# RUN: llvm-mc -filetype=obj -triple riscv64 < %s \
+# RUN: | llvm-objdump -d -riscv-no-aliases - | FileCheck -check-prefix=DISASM %s
+
+# Checks change of options does not cause error: could not find corresponding %pcrel_hi
+# when assembling pseudoinstruction and its extended form.
+
+.option push
+.option norelax
+ la a0, a_symbol
+.option pop
+ la a1, another_symbol
+
+# ASM: .Lpcrel_hi0:
+# ASM: auipc a0, %pcrel_hi(a_symbol)
+# ASM: addi a0, a0, %pcrel_lo(.Lpcrel_hi0)
+# ASM: .Lpcrel_hi1:
+# ASM: auipc a1, %pcrel_hi(another_symbol)
+# ASM: addi a1, a1, %pcrel_lo(.Lpcrel_hi1)
+
+# DISASM: .Lpcrel_hi0:
+# DISASM: auipc a0, 0
+# DISASM: addi a0, a0, 0
+# DISASM:.Lpcrel_hi1:
+# DISASM: auipc a1, 0
+# DISASM: addi a1, a1, 0
+
+.option push
+.option norelax
+1:auipc a0, %pcrel_hi(a_symbol)
+ addi a0, a0, %pcrel_lo(1b)
+.option pop
+2:auipc a1, %pcrel_hi(another_symbol)
+ addi a1, a1, %pcrel_lo(2b)
+
+# ASM: .Ltmp0:
+# ASM: auipc a0, %pcrel_hi(a_symbol)
+# ASM: addi a0, a0, %pcrel_lo(.Ltmp0)
+# ASM: .Ltmp1:
+# ASM: auipc a1, %pcrel_hi(another_symbol)
+# ASM: addi a1, a1, %pcrel_lo(.Ltmp1)
+
+# DISASM: .Ltmp0:
+# DISASM: auipc a0, 0
+# DISASM: addi a0, a0, 0
+# DISASM: .Ltmp1:
+# DISASM: auipc a1, 0
+# DISASM: addi a1, a1, 0
Index: llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp
===================================================================
--- llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp
+++ llvm/trunk/lib/Target/RISCV/MCTargetDesc/RISCVMCExpr.cpp
@@ -49,14 +49,22 @@
if (!AUIPCSRE)
return nullptr;
- const auto *DF =
- dyn_cast_or_null<MCDataFragment>(AUIPCSRE->findAssociatedFragment());
+ const MCSymbol *AUIPCSymbol = &AUIPCSRE->getSymbol();
+ const auto *DF = dyn_cast_or_null<MCDataFragment>(AUIPCSymbol->getFragment());
+
if (!DF)
return nullptr;
- const MCSymbol *AUIPCSymbol = &AUIPCSRE->getSymbol();
+ uint64_t Offset = AUIPCSymbol->getOffset();
+ if (DF->getContents().size() == Offset) {
+ DF = dyn_cast_or_null<MCDataFragment>(DF->getNextNode());
+ if (!DF)
+ return nullptr;
+ Offset = 0;
+ }
+
for (const MCFixup &F : DF->getFixups()) {
- if (F.getOffset() != AUIPCSymbol->getOffset())
+ if (F.getOffset() != Offset)
continue;
switch ((unsigned)F.getKind()) {
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58943.190298.patch
Type: text/x-patch
Size: 2837 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190312/8e4c305c/attachment.bin>
More information about the llvm-commits
mailing list