[PATCH] D43328: [RISCV] Update MC compression tests

Sameer AbuAsal via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 28 19:31:28 PST 2018


sabuasal added inline comments.


================
Comment at: test/MC/RISCV/compress-relocations.s:1-13
+# RUN: llvm-mc -triple riscv32 -mattr=+c -riscv-no-aliases < %s -show-encoding \
+# RUN:     | FileCheck -check-prefix=INSTR -check-prefix=FIXUP %s
+
+# Check prefixes:
+# FIXUP - Check the fixup on the instruction.
+# INSTR - Check the instruction is handled properly by the ASMPrinter
+c.jal foo
----------------
asb wrote:
> asb wrote:
> > You've lost the RELOC checks.
> Also if we're going to separate this to a separate file, relocations-compressed.s would be more consistent with naming of other files (such as fixups-compressed.s).
I actually didn't forget. This is a bit tricky.

MC for RISCV , as of now, only generates relocations if the target for the branch\jump is unresolved. MC also relaxes branches\jumps to unresolved targets (look at MCAssembler::handleFixup and  MCAssembler::fixupNeedsRelaxation).
With relaxation implemented, a compressed branch\jump to an undefined reference will always get relaxed to the expanded form and the relocation generated will be that of the expanded form.

One way this could be circumvented (if we need to) is by implementing shouldForceRelocation, this way a compressed branch to a local (resolved) symbol will also get a relocation.


https://reviews.llvm.org/D43328





More information about the llvm-commits mailing list