RISCV: permit unaligned nop-slide padding emission
authorSaleem Abdulrasool <compnerd@compnerd.org>
Tue, 23 Aug 2022 15:58:36 +0000 (15:58 +0000)
committerSaleem Abdulrasool <compnerd@compnerd.org>
Wed, 24 Aug 2022 20:26:48 +0000 (20:26 +0000)
commit8f45b5a7a90f24ae1dabeff161e22594039a8b0a
tree3b5cb3d7669958eab974a762081c3b195a5cb6ab
parent38d58c1b376d5781f0d293c9811dd3f2d9b3afcf
RISCV: permit unaligned nop-slide padding emission

We may be requested to emit an unaligned nop sequence (e.g. 7-bytes or
3-bytes).  These should be 0-filled even though that is not a valid
instruction.  This matches the behaviour on other architectures like
ARM, X86, and MIPS.  When a custom section is emitted, it may be
classified as text even though it may be a data section or we may be
emitting data into a text segment (e.g. a literal pool).  In such cases,
we should be resilient to the emission request.

This was originally identified by the Linux kernel build and reported on
D131270 by Nathan Chancellor.

Differential Revision: https://reviews.llvm.org/D132482
Reviewed By: luismarques
Tested By: Nathan Chancellor
lld/test/ELF/riscv-relax-align-rvc.s
llvm/lib/Target/RISCV/MCTargetDesc/RISCVAsmBackend.cpp
llvm/test/MC/RISCV/align.s
llvm/test/MC/RISCV/nop-slide.s [new file with mode: 0644]