mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2024-11-24 03:33:20 +01:00
515efbb17e
For RISCV branch instructions, we need to preserve relocation types when linker relaxation enabled, so then linker could modify offset when the branch offsets changed. We preserve relocation types by define shouldForceRelocation. IsResolved return by evaluateFixup will always false when shouldForceRelocation return true. It will make RISCV MC Branch Relaxation always relax 16-bit branches to 32-bit form, even if the symbol actually could be resolved. To avoid 16-bit branches always relax to 32-bit form when linker relaxation enabled, we add a new parameter WasForced to indicate that the symbol actually couldn't be resolved and not forced by shouldForceRelocation return true. RISCVAsmBackend::fixupNeedsRelaxationAdvanced could relax branches with unresolved symbols by (!IsResolved && !WasForced). RISCV MC Branch Relaxation is needed because RISCV could perform 32-bit to 16-bit transformation in MC layer. Differential Revision: https://reviews.llvm.org/D46350 llvm-svn: 332696
23 lines
1003 B
ArmAsm
23 lines
1003 B
ArmAsm
# RUN: llvm-mc -triple riscv32 -mattr=+c -riscv-no-aliases < %s -show-encoding \
|
|
# RUN: | FileCheck -check-prefix=INSTR -check-prefix=FIXUP %s
|
|
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+c < %s \
|
|
# RUN: | llvm-readobj -r | FileCheck -check-prefix=RELOC %s
|
|
# RUN: llvm-mc -filetype=obj -triple riscv32 -mattr=+c,+relax < %s \
|
|
# RUN: | llvm-readobj -r | FileCheck -check-prefix=RELOC %s
|
|
|
|
# Check prefixes:
|
|
# RELOC - Check the relocation in the object.
|
|
# FIXUP - Check the fixup on the instruction.
|
|
# INSTR - Check the instruction is handled properly by the ASMPrinter
|
|
c.jal foo
|
|
# A compressed jump (c.j) to an unresolved symbol will be relaxed to a (jal).
|
|
# RELOC: R_RISCV_JAL
|
|
# INSTR: c.jal foo
|
|
# FIXUP: fixup A - offset: 0, value: foo, kind: fixup_riscv_rvc_jump
|
|
|
|
c.bnez a0, foo
|
|
# A compressed branch (c.bnez) to an unresolved symbol will be relaxed to a (bnez).
|
|
# RELOC: R_RISCV_BRANCH
|
|
# INSTR: c.bnez a0, foo
|
|
# FIXUP: fixup A - offset: 0, value: foo, kind: fixup_riscv_rvc_branch
|