[RISCV] Insert R_RISCV_ALIGN relocation type and Nops for code alignment when linker...
authorShiva Chen <shiva0217@gmail.com>
Wed, 30 Jan 2019 11:16:59 +0000 (11:16 +0000)
committerShiva Chen <shiva0217@gmail.com>
Wed, 30 Jan 2019 11:16:59 +0000 (11:16 +0000)
commit5af037f1e9635821bf9a5792d29d9ca43862d891
treeb127af9bc7e56210c8306692694494511cb6a36e
parentd17f6ab61b2492cdf5c1c88c36915456206f84fe
[RISCV] Insert R_RISCV_ALIGN relocation type and Nops for code alignment when linker relaxation enabled

Linker relaxation may change code size. We need to fix up the alignment
of alignment directive in text section by inserting Nops and R_RISCV_ALIGN
relocation type. So then linker could satisfy the alignment by removing Nops.

To do this:

1. Add shouldInsertExtraNopBytesForCodeAlign target hook to calculate
   the Nops we need to insert.

2. Add shouldInsertFixupForCodeAlign target hook to insert
   R_RISCV_ALIGN fixup type.

Differential Revision: https://reviews.llvm.org/D47755

llvm-svn: 352616
llvm/include/llvm/MC/MCAsmBackend.h
llvm/lib/MC/MCAssembler.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.h
llvm/lib/Target/RISCV/MCTargetDesc/RISCVELFObjectWriter.cpp
llvm/lib/Target/RISCV/MCTargetDesc/RISCVFixupKinds.h
llvm/test/MC/RISCV/align.s [new file with mode: 0644]