[PATCH] D46630: [RISCV] Insert NOPs and R_RISCV_ALIGN relocation type for .align directive when linker relaxation enabled

Shiva Chen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue May 8 23:45:04 PDT 2018


shiva0217 created this revision.
shiva0217 added reviewers: asb, apazos.
Herald added subscribers: mgrang, edward-jones, zzheng, kito-cheng, niosHD, sabuasal, jordy.potman.lists, simoncook, johnrusso, rbar.

.align N alignment fixed by assembler may be changed when the linker relaxation enabled.
In this case, we have to insert N-2 bytes NOPs and R_RISCV_ALIGN relocation type.
In this way, Linker could detect R_RISCV_ALIGN and fix the alignment by removing
NOPs.

To do this:

1. Add parseDirectiveAlign in RISCVAsmParser to parse .align and .p2align directive and then insert PseudoNOPs instruction.

2. Add expandNOPs in RISCVMCCodeEmitter to expand PseudoNOPs to NOPs with R_RISCV_ALIGN relocation type.

3. Add disablePaddingAlignment target hook in MCAsmBackend to disable generic padding for .align and let PseudoNOPs deal with it.


Repository:
  rL LLVM

https://reviews.llvm.org/D46630

Files:
  include/llvm/MC/MCAsmBackend.h
  lib/MC/MCAssembler.cpp
  lib/Target/RISCV/AsmParser/RISCVAsmParser.cpp
  lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
  lib/Target/RISCV/MCTargetDesc/RISCVELFObjectWriter.cpp
  lib/Target/RISCV/MCTargetDesc/RISCVFixupKinds.h
  lib/Target/RISCV/MCTargetDesc/RISCVMCCodeEmitter.cpp
  lib/Target/RISCV/RISCVInstrInfo.td
  test/MC/RISCV/align.s

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D46630.145867.patch
Type: text/x-patch
Size: 12092 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180509/b80de7bc/attachment.bin>


More information about the llvm-commits mailing list