[PATCH] D46423: [WIP, RISCV] Support .option relax and .option norelax

Lewis Revill via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Sep 25 01:39:56 PDT 2018


lewis-revill updated this revision to Diff 166827.
lewis-revill added a comment.

So, I've updated this patch with what I believe is a good compromise. The AsmParser will check when it is parsing an instruction whether relaxation is enabled at that point, and if it is, the `ForceRelocs` field is set. In AsmBackend, `ForceRelocs` is now the only variable that affects whether relocations are emitted.

This allows the case where an early `.option norelax` is used to not emit unnecessary relocations. A test was also added for this case (`option-norelax-override.s`). Unfortunately the tests that currently test relocations would fail unless an instruction occured in the file to trigger `ForceRelocs` to be set, so some instructions had to be added to these files.

The compromise is that any instructions occuring during a relaxation section will cause `ForceRelocs` to be set, regardless of whether the instruction itself may be relaxed (explained in the comment in `RISCVAsmParser.cpp`).


Repository:
  rL LLVM

https://reviews.llvm.org/D46423

Files:
  lib/MC/MCAsmStreamer.cpp
  lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
  lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h
  lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.cpp
  lib/Target/RISCV/MCTargetDesc/RISCVELFStreamer.h
  lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.cpp
  lib/Target/RISCV/MCTargetDesc/RISCVTargetStreamer.h
  test/MC/RISCV/fixups-expr.s
  test/MC/RISCV/hilo-constaddr-expr.s
  test/MC/RISCV/option-invalid.s
  test/MC/RISCV/option-norelax-override.s
  test/MC/RISCV/option-relax.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46423.166827.patch
Type: text/x-patch
Size: 21293 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180925/95837eec/attachment-0001.bin>


More information about the llvm-commits mailing list