llvm-project/llvm/test/MC/RISCV
James Clarke 3f5976c97d [RISCV] Fix evaluating %pcrel_lo against global and weak symbols
Summary:
Previously, we would erroneously turn %pcrel_lo(label), where label has
a %pcrel_hi against a weak symbol, into %pcrel_lo(label + offset), as
evaluatePCRelLo would believe the target independent logic was going to
fold it. Moreover, even if that were fixed, shouldForceRelocation lacks
an MCAsmLayout and thus cannot evaluate the %pcrel_hi fixup to a value
and check the symbol, so we would then erroneously constant-fold the
%pcrel_lo whilst leaving the %pcrel_hi intact. After D72197, this same
sequence also occurs for symbols with global binding, which is triggered
in real-world code.

Instead, as discussed in D71978, we introduce a new FKF_IsTarget flag to
avoid these kinds of issues. All the resolution logic happens in one
place, with no coordination required between RISCAsmBackend and
RISCVMCExpr to ensure they implement the same logic twice. Although the
implementation of %pcrel_hi can be left as target independent, we make
it target dependent to ensure that they are handled identically to
%pcrel_lo, otherwise we risk one of them being constant folded but the
other being preserved. This also allows us to properly support fixup
pairs where the instructions are in different fragments.

Reviewers: asb, lenary, efriedma

Reviewed By: efriedma

Subscribers: arichardson, hiraditya, rbar, johnrusso, simoncook, sabuasal, niosHD, kito-cheng, shiva0217, MaskRay, zzheng, edward-jones, rogfer01, MartinMosbeck, brucehoult, the_o, rkruppe, PkmX, jocewei, psnobl, benna, Jim, s.egerton, pzheng, sameer.abuasal, apazos, luismarques, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D73211
2020-01-23 02:05:48 +00:00
..
align.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
cfi-regs-invalid.s [RISCV] Fix RISCVAsmParser::ParseRegister and add tests 2019-03-17 12:00:58 +00:00
cfi-regs-valid.s [RISCV] Fix RISCVAsmParser::ParseRegister and add tests 2019-03-17 12:00:58 +00:00
cnop.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
compress-cjal.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
compress-debug-info.s [RISCV] Move DebugLoc Copy into CompressInstEmitter 2019-12-13 20:01:04 +00:00
compress-rv32d.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
compress-rv32f.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
compress-rv32i.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
compress-rv64i.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
compressed-relocations.s
csr-aliases.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
data-directives-invalid.s
data-directives-valid.s
elf-flags.s [llvm-readobj] Change -long-option to --long-option in tests. NFC 2019-05-01 05:27:20 +00:00
elf-header.s
empty-string.s
fde-reloc.s [RISCV] Implement getExprForFDESymbol to ensure RISCV_32_PCREL is used for the FDE location 2019-08-20 12:32:31 +00:00
fixups-compressed.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
fixups-diagnostics.s
fixups-expr.s
fixups-invalid.s [RISCV] Don't crash on unsupported relocations 2019-12-19 17:21:30 +00:00
fixups.s [RISCV][NFC] Trivial cleanup 2019-12-17 11:44:35 +00:00
function-call-invalid.s [RISCV] Add pseudo instruction for calls with explicit register 2019-06-26 10:35:58 +00:00
function-call.s [RISCV] Add pseudo instruction for calls with explicit register 2019-06-26 10:35:58 +00:00
hilo-constaddr-expr.s
hilo-constaddr.s
invalid-instruction-spellcheck.s [RISCV] Add assembly mnemonic spell checking 2019-11-18 10:58:00 +00:00
linker-relaxation.s [RISCV] Don't force absolute FK_Data_X fixups to relocs 2019-08-19 13:23:02 +00:00
lit.local.cfg [lit] Delete empty lines at the end of lit.local.cfg NFC 2019-06-17 09:51:07 +00:00
lla-invalid.s [RISCV] Support assembling @plt symbol operands 2019-04-02 12:47:20 +00:00
machine-csr-names-invalid.s
machine-csr-names.s
mattr-invalid-combination.s Revert "[Support] make report_fatal_error `abort` instead of `exit`" 2020-01-15 17:52:25 -08:00
numeric-reg-names-d.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
numeric-reg-names-f.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
numeric-reg-names.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
option-invalid.s
option-mix.s [RISCV] Fix evalutePCRelLo for symbols at the end of a fragment 2020-01-08 04:32:06 +00:00
option-pushpop.s
option-relax.s [RISCV] Don't evaluatePCRelLo if a relocation will be forced (e.g. due to linker relaxation) 2019-04-01 02:38:27 +00:00
option-rvc.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
pcrel-fixups.s [RISCV] Fix evaluating %pcrel_lo against global and weak symbols 2020-01-23 02:05:48 +00:00
pcrel-lo12-invalid.s [RISCV] Fix evaluating %pcrel_lo against global and weak symbols 2020-01-23 02:05:48 +00:00
priv-invalid.s
priv-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
relocations.s [RISCV] Support assembling %tls_{ie,gd}_pcrel_hi modifiers 2019-04-23 14:46:13 +00:00
rv32-machine-csr-names.s
rv32-relaxation.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rv32-user-csr-names.s
rv32a-invalid.s [RISCV] Add Custom Parser for Atomic Memory Operands 2019-08-01 12:42:31 +00:00
rv32a-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rv32c-aliases-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rv32c-fuzzed-invalid.s
rv32c-invalid.s [RISCV] Improve assembler missing feature warnings 2019-12-10 16:44:48 +00:00
rv32c-only-valid.s [RISCV] Improve assembler missing feature warnings 2019-12-10 16:44:48 +00:00
rv32c-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rv32d-invalid.s [RISCV] Support assembling TLS add and associated modifiers 2019-04-04 14:13:37 +00:00
rv32d-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rv32dc-invalid.s
rv32dc-valid.s [RISCV] Improve assembler missing feature warnings 2019-12-10 16:44:48 +00:00
rv32e-invalid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rv32e-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rv32f-invalid.s [RISCV] Improve assembler missing feature warnings 2019-12-10 16:44:48 +00:00
rv32f-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rv32fc-aliases-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rv32fc-invalid.s
rv32fc-valid.s [RISCV] Improve assembler missing feature warnings 2019-12-10 16:44:48 +00:00
rv32i-aliases-invalid.s [RISCV] Improve assembler missing feature warnings 2019-12-10 16:44:48 +00:00
rv32i-aliases-valid.s [RISCV] Fix evaluating %pcrel_lo against global and weak symbols 2020-01-23 02:05:48 +00:00
rv32i-invalid.s [RISCV] Improve assembler missing feature warnings 2019-12-10 16:44:48 +00:00
rv32i-valid.s [RISCV] Fix evaluating %pcrel_lo against global and weak symbols 2020-01-23 02:05:48 +00:00
rv32m-invalid.s [RISCV] Improve assembler missing feature warnings 2019-12-10 16:44:48 +00:00
rv32m-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rv64-machine-csr-names.s
rv64-relaxation.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rv64-user-csr-names.s
rv64a-aliases-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rv64a-invalid.s [RISCV] Add Custom Parser for Atomic Memory Operands 2019-08-01 12:42:31 +00:00
rv64a-valid.s [RISCV] Improve assembler missing feature warnings 2019-12-10 16:44:48 +00:00
rv64c-aliases-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rv64c-hints-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rv64c-invalid.s
rv64c-valid.s [RISCV] Improve assembler missing feature warnings 2019-12-10 16:44:48 +00:00
rv64d-aliases-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rv64d-invalid.s
rv64d-valid.s [RISCV] Improve assembler missing feature warnings 2019-12-10 16:44:48 +00:00
rv64dc-valid.s [RISCV] Improve assembler missing feature warnings 2019-12-10 16:44:48 +00:00
rv64f-aliases-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rv64f-invalid.s
rv64f-valid.s [RISCV] Improve assembler missing feature warnings 2019-12-10 16:44:48 +00:00
rv64i-aliases-invalid.s [RISCV] Improve assembler missing feature warnings 2019-12-10 16:44:48 +00:00
rv64i-aliases-valid.s [RISCV] Fix evaluating %pcrel_lo against global and weak symbols 2020-01-23 02:05:48 +00:00
rv64i-invalid.s [RISCV] Support assembling TLS add and associated modifiers 2019-04-04 14:13:37 +00:00
rv64i-pseudos.s [RISCV] Implement pseudo instructions for load/store from a symbol address. 2019-02-20 03:31:32 +00:00
rv64i-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rv64m-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rva-aliases-invalid.s [RISCV] Check register class for AMO memory operands 2020-01-13 00:50:37 +00:00
rva-aliases-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rvc-aliases-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rvc-hints-invalid.s [RISCV] Add support for RVC HINT instructions 2019-08-21 14:00:58 +00:00
rvc-hints-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rvd-aliases-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rvd-pseudos.s [RISCV] Implement pseudo instructions for load/store from a symbol address. 2019-02-20 03:31:32 +00:00
rvdc-aliases-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rvf-aliases-valid.s [RISCV] Add obsolete aliases of fscsr, frcsr (fssr, frsr) 2019-10-03 15:47:28 +00:00
rvf-pseudos.s [RISCV] Implement pseudo instructions for load/store from a symbol address. 2019-02-20 03:31:32 +00:00
rvf-user-csr-names.s [RISCV] Allow access to FP CSRs without F extension 2019-03-08 23:01:08 +00:00
rvi-aliases-valid.s [RISCV] Support llvm-objdump -M no-aliases and -M numeric 2019-09-10 16:24:03 +00:00
rvi-alternate-abi-names.s [RISCV] Allow fp as an alias of s0 2019-03-11 21:35:26 +00:00
rvi-pseudos-invalid.s [RISCV][NFC] Correct RUN in rvi-pseudos-invalid.s 2019-07-23 17:14:42 +00:00
rvi-pseudos.s [RISCV] Allow parsing of bare symbols with offsets 2019-08-16 12:00:56 +00:00
supervisor-csr-names.s
tail-call-invalid.s
tail-call.s [RISCV] Support assembling @plt symbol operands 2019-04-02 12:47:20 +00:00
target-abi-invalid.s [RISCV] Add basic RV32E definitions and MC layer support 2019-03-22 11:21:40 +00:00
target-abi-valid.s [llvm-readobj] Change -long-option to --long-option in tests. NFC 2019-05-01 05:27:20 +00:00
user-csr-names-invalid.s [RISCV] Allow access to FP CSRs without F extension 2019-03-08 23:01:08 +00:00
user-csr-names.s