llvm-project/llvm/test/CodeGen/BPF
Yonghong Song 87cba43402 BPF: add a SimplifyCFG IR pass during generic Scalar/IPO optimization
The following bpf linux kernel selftest failed with latest
llvm:
  $ ./test_progs -n 7/10
  ...
  The sequence of 8193 jumps is too complex.
  verification time 126272 usec
  stack depth 320
  processed 114799 insns (limit 1000000)
  ...
  libbpf: failed to load object 'pyperf600_nounroll.o'
  test_bpf_verif_scale:FAIL:110
  #7/10 pyperf600_nounroll.o:FAIL
  #7 bpf_verif_scale:FAIL

After some investigation, I found the following llvm patch
  https://reviews.llvm.org/D84108
is responsible. The patch disabled hoisting common instructions
in SimplifyCFG by default. Later on, the code changes and a
SimplifyCFG phase with hoisting on cannot do the work any more.

A test is provided to demonstrate the problem.
The IR before simplifyCFG looks like:
  for.cond:
    %i.0 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
    %cmp = icmp ult i32 %i.0, 6
    br i1 %cmp, label %for.body, label %for.cond.cleanup

  for.cond.cleanup:
    %2 = load i8*, i8** %frame_ptr, align 8, !tbaa !2
    %cmp2 = icmp eq i8* %2, null
    %conv = zext i1 %cmp2 to i32
    call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %1) #3
    call void @llvm.lifetime.end.p0i8(i64 8, i8* nonnull %0) #3
    ret i32 %conv

  for.body:
    %3 = load i8*, i8** %frame_ptr, align 8, !tbaa !2
    %tobool.not = icmp eq i8* %3, null
    br i1 %tobool.not, label %for.inc, label %land.lhs.true

The first two insns of `for.cond.cleanup` and `for.body`, load and
icmp, can be hoisted to `for.cond` block. With Patch D84108, the
optimization is delayed. But unfortunately, later on loop rotation
added addition phi nodes to `for.body` and hoisting cannot
be done any more.

Note such a hoisting is beneficial to bpf programs as
bpf verifier does path sensitive analysis and verification.
The hoisting preverts reloading from stack which will assume
conservative value and increase exploited insns. In this case,
it caused verifier failure.

To fix this problem, I added an IR pass from bpf target
to performance additional simplifycfg with hoisting common inst
enabled.

Differential Revision: https://reviews.llvm.org/D85434
2020-08-06 13:16:00 -07:00
..
BTF BPF: simplify IR generation for __builtin_btf_type_id() 2020-08-04 16:29:42 -07:00
CORE BPF: support type exist/size and enum exist/value relocations 2020-08-04 12:35:39 -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 [llvm-readobj] Update tests because of changes in llvm-readobj behavior 2020-07-20 10:39:04 +01:00
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
rodata_5.ll [BPF] fix incorrect type in BPFISelDAGToDAG readonly load optimization 2020-06-11 19:31:06 -07: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
simplifycfg.ll BPF: add a SimplifyCFG IR pass during generic Scalar/IPO optimization 2020-08-06 13:16:00 -07: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