diff options
author | Yonghong Song <yhs@fb.com> | 2019-10-24 22:57:06 -0700 |
---|---|---|
committer | Yonghong Song <yhs@fb.com> | 2019-10-25 14:27:25 -0700 |
commit | a27c998c0060eef006ca9e225e4d12a35f4d1912 (patch) | |
tree | 87a605f6ca4cc41d8712ca36395b2cd30ad9445f /llvm/test/CodeGen/BPF/CORE/offset-reloc-struct-array.ll | |
parent | e070cf81196d2415f2f64ddbdfed9a49d9b96245 (diff) | |
download | bcm5719-llvm-a27c998c0060eef006ca9e225e4d12a35f4d1912.tar.gz bcm5719-llvm-a27c998c0060eef006ca9e225e4d12a35f4d1912.zip |
[BPF] fix a CO-RE issue with -mattr=+alu32
Ilya Leoshkevich (<iii@linux.ibm.com>) reported an issue that
with -mattr=+alu32 CO-RE has a segfault in BPF MISimplifyPatchable
pass.
The pattern will be transformed by MISimplifyPatchable
pass looks like below:
r5 = ld_imm64 @"b:0:0$0:0"
r2 = ldw r5, 0
... r2 ... // use r2
The pass will remove the intermediate 'ldw' instruction
and replacing all r2 with r5 likes below:
r5 = ld_imm64 @"b:0:0$0:0"
... r5 ... // use r5
Later, the ld_imm64 insn will be replaced with
r5 = <patched immediate>
for field relocation purpose.
With -mattr=+alu32, the input code may become
r5 = ld_imm64 @"b:0:0$0:0"
w2 = ldw32 r5, 0
... w2 ... // use w2
Replacing "w2" with "r5" is incorrect and will
trigger compiler internal errors.
To fix the problem, if the register class of ldw* dest
register is sub_32, we just replace the original ldw*
register with:
w2 = w5
Directly replacing all uses of w2 with in-place
constructed w5 for the use operand seems not working in all cases.
The latest kernel will have -mattr=+alu32 on by default,
so added this flag to all CORE tests.
Tested with latest kernel bpf-next branch as well with this patch.
Differential Revision: https://reviews.llvm.org/D69438
Diffstat (limited to 'llvm/test/CodeGen/BPF/CORE/offset-reloc-struct-array.ll')
-rw-r--r-- | llvm/test/CodeGen/BPF/CORE/offset-reloc-struct-array.ll | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/llvm/test/CodeGen/BPF/CORE/offset-reloc-struct-array.ll b/llvm/test/CodeGen/BPF/CORE/offset-reloc-struct-array.ll index d4590bb8a59..c88454f0a1f 100644 --- a/llvm/test/CodeGen/BPF/CORE/offset-reloc-struct-array.ll +++ b/llvm/test/CodeGen/BPF/CORE/offset-reloc-struct-array.ll @@ -1,5 +1,7 @@ ; RUN: llc -march=bpfel -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s ; RUN: llc -march=bpfeb -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s +; RUN: llc -march=bpfel -mattr=+alu32 -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s +; RUN: llc -march=bpfeb -mattr=+alu32 -filetype=asm -o - %s | FileCheck -check-prefixes=CHECK %s ; Source code: ; struct net_device { ; int dev_id; @@ -128,8 +130,8 @@ define dso_local i32 @bpf_prog(%struct.sk_buff*) local_unnamed_addr #0 !dbg !15 ; CHECK-NEXT: .long 0 ; CHECK-NEXT: .long 20 ; CHECK-NEXT: .long 20 -; CHECK-NEXT: .long 76 -; CHECK-NEXT: .long 96 +; CHECK-NEXT: .long {{[0-9]+}} +; CHECK-NEXT: .long {{[0-9]+}} ; CHECK-NEXT: .long 28 ; CHECK-NEXT: .long 8 # FuncInfo |