Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
- Loading branch information
Showing
4 changed files
with
46 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# RUN: llvm-mc -triple riscv64 -mattr +c,-relax -filetype obj -o - %s | llvm-objdump -d - | FileCheck %s -check-prefix CHECK-RVC-NORELAX | ||
# RUN: llvm-mc -triple riscv64 -mattr +c,+relax -filetype obj -o - %s | llvm-objdump -d - | FileCheck %s -check-prefix CHECK-RVC-RELAX | ||
# RUN: llvm-mc -triple riscv64 -mattr -c,-relax -filetype obj -o - %s | llvm-objdump -d - | FileCheck %s | ||
# RUN: llvm-mc -triple riscv64 -mattr -c,+relax -filetype obj -o - %s | llvm-objdump -d - | FileCheck %s | ||
|
||
.balign 4 | ||
.byte 0 | ||
|
||
.balign 4 | ||
auipc a0, 0 | ||
|
||
# CHECK-RVC-NORELAX: 0000000000000000 <.text>: | ||
# CHECK-RVC-NORELAX-NEXT: 0: 00 00 unimp | ||
# CHECK-RVC-NORELAX-NEXT: 2: 01 00 nop | ||
# CHECK-RVC-NORELAX-NEXT: 4: 17 05 00 00 auipc a0, 0 | ||
|
||
# CHECK-RVC-RELAX: 0000000000000000 <.text>: | ||
# CHECK-RVC-RELAX-NEXT: 0: 01 00 nop | ||
# CHECK-RVC-RELAX-NEXT: 2: 00 01 addi s0, sp, 128 | ||
# CHECK-RVC-RELAX-NEXT: 4: 00 17 addi s0, sp, 928 | ||
# CHECK-RVC-RELAX-NEXT: 6: 05 00 c.nop 1 | ||
# CHECK-RVC-RELAX-NEXT: 8: 00 <unknown> | ||
|
||
# CHECK: 0000000000000000 <.text>: | ||
# CHECK-NEXT: 0: 00 00 <unknown> | ||
# CHECK-NEXT: 2: 00 00 <unknown> | ||
# CHECK-NEXT: 4: 17 05 00 00 auipc a0, 0 |