llvm-project/llvm/test/CodeGen/BPF
Yonghong Song 3659559cf3 [BPF] Remove unnecessary MOV_32_64 instructions
Commit 13f6c81c5d ("[BPF] simplify zero extension
with MOV_32_64") tried to use MOV_32_64 instructions
instead of lshift/rshift instructions for zero extension.
This has the benefit to remove the number of instructions
and may help verifier too.

But the same commit also removed the old MOV_32_64
pruning as it deems unsafe as MOV_32_64 does have the
side effect, zeroing out the top 32bit in the register.
This caused the following failure in kernel selftest
test_cls_redirect.o. In linux kernel, we have
     struct __sk_buff {
        __u32 data;
        __u32 data_end;
     };
The compiler will generate 32bit load for __sk_buff->data
and __sk_buff->data_end. But kernel verifier will actually
loads an address (64bit address on 64bit kernel) to the
result register. In this particular example, the explicit zext
was not optimized away and destroyed top 32bit
address and the verifier rejected the program :
     w2 = *(u32 *)(r1 + 76)
     ...
     r2 = w2  /* MOV_32_64: this will clear top 32bit */

Currently, if the load and the zext are next to each other, the
instruction pattern match can actually capture this to
avoid MOV_32_64, e.g., in BPFInstrInfo.td, we have
  def : Pat<(i64 (zextloadi32 ADDRri:$src)),
            (SUBREG_TO_REG (i64 0), (LDW32 ADDRri:$src), sub_32)>;

However, if they are not next to each other, LDW32 and
MOV_32_64 are generated, which may cause the above mentioned
problem.

BPF Backend already tried to optimize away pattern
   mov_32_64 + lshift + rshift

Commit 13f6c81c5d may generate mov_32_64 not followed by shifts.
This patch added optimization for only mov_32_64 too.

Differential Revision: https://reviews.llvm.org/D81048
2020-06-03 08:14:54 -07:00
..
BTF [BPF] preserve debuginfo types for builtin __builtin__btf_type_id() 2020-05-15 08:00:44 -07:00
CORE BPF: fix a CORE optimization bug 2020-04-20 19:54:51 -07:00
32-bit-subreg-alu.ll [BPF] turn on -mattr=+alu32 for cpu version v3 and later 2019-11-07 22:08:46 -08:00
32-bit-subreg-cond-select.ll [BPF] simplify zero extension with MOV_32_64 2020-05-27 11:26:39 -07:00
32-bit-subreg-load-store.ll
32-bit-subreg-peephole-phi-1.ll [BPF] simplify zero extension with MOV_32_64 2020-05-27 11:26:39 -07:00
32-bit-subreg-peephole-phi-2.ll [BPF] simplify zero extension with MOV_32_64 2020-05-27 11:26:39 -07:00
32-bit-subreg-peephole-phi-3.ll [BPF] simplify zero extension with MOV_32_64 2020-05-27 11:26:39 -07:00
32-bit-subreg-peephole.ll [BPF] simplify zero extension with MOV_32_64 2020-05-27 11:26:39 -07:00
32-bit-subreg-zext.ll [BPF] simplify zero extension with MOV_32_64 2020-05-27 11:26:39 -07:00
alu8.ll
atomics.ll
basictest.ll
byval.ll
callx.ll [BPF] fix indirect call assembly code 2019-10-21 03:22:03 +00:00
cc_args.ll
cc_args_be.ll
cc_ret.ll
cmp.ll
dwarfdump.ll Migrate function attribute "no-frame-pointer-elim" to "frame-pointer"="all" as cleanups after D56351 2019-12-24 15:57:33 -08:00
elf-symbol-information.ll
ex1.ll
fi_ri.ll
i128.ll [BPF] support 128bit int explicitly in layout spec 2020-03-28 11:46:29 -07:00
inline_asm.ll
inlineasm-output-template.ll
intrinsics.ll
is_trunc_free.ll [BPF] implement isTruncateFree and isZExtFree in BPFTargetLowering 2020-02-11 09:59:19 -08:00
is_zext_free.ll [BPF] implement isTruncateFree and isZExtFree in BPFTargetLowering 2020-02-11 09:59:19 -08:00
lit.local.cfg
load.ll
loops.ll
many_args1.ll
many_args2.ll
mem_offset.ll
mem_offset_be.ll
memcpy-expand-in-order.ll
objdump_atomics.ll
objdump_cond_op.ll [llvm-objdump] -d: print `00000000 <foo>:` instead of `00000000 foo:` 2020-03-05 18:05:28 -08:00
objdump_cond_op_2.ll [llvm-objdump] -d: print `00000000 <foo>:` instead of `00000000 foo:` 2020-03-05 18:05:28 -08:00
objdump_dis_all.ll [BPF] Return fail if disassembled insn registers out of range 2020-05-18 18:53:23 -07:00
objdump_imm_hex.ll [test] llvm/test/: change llvm-objdump single-dash long options to double-dash options 2020-03-15 17:46:23 -07:00
objdump_intrinsics.ll
objdump_nop.ll [BPF] Prevent disassembly segfault for NOP insn 2020-05-18 17:40:18 -07:00
objdump_static_var.ll
objdump_trivial.ll
objdump_two_funcs.ll [llvm-objdump] -d: print `00000000 <foo>:` instead of `00000000 foo:` 2020-03-05 18:05:28 -08:00
optnone-1.ll [BPF] fix a bug in BPFMISimplifyPatchable pass with -O0 2020-01-30 08:28:39 -08:00
reloc-btf-2.ll [llvm-objdump] Print file format in lowercase to match GNU output. 2020-02-12 08:17:01 -08:00
reloc-btf.ll [llvm-objdump] Print file format in lowercase to match GNU output. 2020-02-12 08:17:01 -08:00
reloc.ll [llvm-objdump] Print file format in lowercase to match GNU output. 2020-02-12 08:17:01 -08:00
remove_truncate_1.ll
remove_truncate_2.ll
remove_truncate_3.ll
remove_truncate_4.ll
remove_truncate_5.ll
remove_truncate_6.ll bpf: fix wrong truncation elimination when there is back-edge/loop 2019-10-16 15:27:59 +00:00
remove_truncate_7.ll [BPF] Remove unnecessary MOV_32_64 instructions 2020-06-03 08:14:54 -07:00
rodata_1.ll
rodata_2.ll
rodata_3.ll
rodata_4.ll [llvm] Fix missing FileCheck directive colons 2020-04-06 09:59:08 -06:00
sanity.ll
sdiv_error.ll Revert "Revert "Reland "[Support] make report_fatal_error `abort` instead of `exit`""" 2020-02-13 10:16:06 -08:00
select_ri.ll
setcc.ll
shifts.ll [SelectionDAG] ComputeKnownBits - minimum leading/trailing zero bits in LSHR/SHL (PR44526) 2020-01-13 11:08:12 +00:00
sockex2.ll
struct_ret1.ll
struct_ret2.ll
undef.ll
vararg1.ll
warn-call.ll
warn-stack.ll Migrate function attribute "no-frame-pointer-elim" to "frame-pointer"="all" as cleanups after D56351 2019-12-24 15:57:33 -08:00
xadd.ll Revert "Revert "Reland "[Support] make report_fatal_error `abort` instead of `exit`""" 2020-02-13 10:16:06 -08:00
xadd_legal.ll