llvm-project/llvm/test/CodeGen/BPF/CORE
Yonghong Song 3cb7e7bf95 BPF: fix a CORE optimization bug
For the test case in this patch like below
  struct t { int a; } __attribute__((preserve_access_index));
  int foo(void *);
  int test(struct t *arg) {
      long param[1];
      param[0] = (long)&arg->a;
      return foo(param);
  }

The IR right before BPF SimplifyPatchable phase:
  %1:gpr = LD_imm64 @"llvm.t:0:0$0:0"
  %2:gpr = LDD killed %1:gpr, 0
  %3:gpr = ADD_rr %0:gpr(tied-def 0), killed %2:gpr
  STD killed %3:gpr, %stack.0.param, 0
After SimplifyPatchable phase, the incorrect IR is generated:
  %1:gpr = LD_imm64 @"llvm.t:0:0$0:0"
  %3:gpr = ADD_rr %0:gpr(tied-def 0), killed %1:gpr
  CORE_MEM killed %3:gpr, 306, %0:gpr, @"llvm.t:0:0$0:0"

Note that CORE_MEM pseudo op is introduced to encode
memory operations related to CORE. In the above, we intend
to check whether we have a store like
   *(%3:gpr + 0) = ...
and if this is the case, we could replace it with
   *(%0:gpr + @"llvm.t:0:0$0:0"_ = ...

Unfortunately, in the above, IR for the store is
   *(%stack.0.param + 0) = %3:gpr
and transformation should not happen.

Note that we won't have problem if the actual CORE
dereference (arg->a) happens.

This patch fixed the problem by skip CORE optimization if
the use of ADD_rr result is not the base address of the store
operation.

Differential Revision: https://reviews.llvm.org/D78466
2020-04-20 19:54:51 -07:00
..
field-reloc-alu32.ll
field-reloc-bitfield-1.ll [BPF] Fix CO-RE bugs with bitfields 2019-11-04 20:08:05 -08:00
field-reloc-bitfield-2.ll [BPF] Fix CO-RE bugs with bitfields 2019-11-04 20:08:05 -08:00
intrinsic-array.ll Migrate function attribute "no-frame-pointer-elim" to "frame-pointer"="all" as cleanups after D56351 2019-12-24 15:57:33 -08:00
intrinsic-fieldinfo-byte-size-1.ll
intrinsic-fieldinfo-byte-size-2.ll
intrinsic-fieldinfo-byte-size-3.ll
intrinsic-fieldinfo-byte-size-4.ll
intrinsic-fieldinfo-existence-1.ll
intrinsic-fieldinfo-existence-2.ll
intrinsic-fieldinfo-existence-3.ll
intrinsic-fieldinfo-lshift-1.ll
intrinsic-fieldinfo-lshift-2.ll
intrinsic-fieldinfo-rshift-1.ll
intrinsic-fieldinfo-rshift-2.ll
intrinsic-fieldinfo-rshift-3.ll
intrinsic-fieldinfo-signedness-1.ll
intrinsic-fieldinfo-signedness-2.ll
intrinsic-fieldinfo-signedness-3.ll
intrinsic-struct.ll Migrate function attribute "no-frame-pointer-elim" to "frame-pointer"="all" as cleanups after D56351 2019-12-24 15:57:33 -08:00
intrinsic-transforms.ll
intrinsic-union.ll Migrate function attribute "no-frame-pointer-elim" to "frame-pointer"="all" as cleanups after D56351 2019-12-24 15:57:33 -08:00
no-elf-ama-symbol.ll [BPF] add "llvm." prefix to BPF internally created globals 2019-11-25 21:34:46 -08:00
no-narrow-load.ll [BPF] disable ReduceLoadWidth during SelectionDag phase 2020-02-04 18:37:43 -08:00
offset-reloc-access-str.ll
offset-reloc-basic.ll [BPF] extend BTF_KIND_FUNC to cover global, static and extern funcs 2020-01-10 09:06:31 -08:00
offset-reloc-cast-array-1.ll
offset-reloc-cast-array-2.ll
offset-reloc-cast-struct-1.ll
offset-reloc-cast-struct-2.ll
offset-reloc-cast-struct-3.ll
offset-reloc-cast-union-1.ll
offset-reloc-cast-union-2.ll
offset-reloc-end-load.ll [BPF] Enable relocation location for load/store/shifts 2019-12-26 09:07:39 -08:00
offset-reloc-end-ret.ll
offset-reloc-fieldinfo-1.ll [BPF] implement isTruncateFree and isZExtFree in BPFTargetLowering 2020-02-11 09:59:19 -08:00
offset-reloc-fieldinfo-2.ll [BPF] implement isTruncateFree and isZExtFree in BPFTargetLowering 2020-02-11 09:59:19 -08:00
offset-reloc-global-1.ll
offset-reloc-global-2.ll
offset-reloc-global-3.ll
offset-reloc-ignore.ll
offset-reloc-middle-chain.ll
offset-reloc-multi-array-1.ll
offset-reloc-multi-array-2.ll
offset-reloc-multilevel.ll [BPF] extend BTF_KIND_FUNC to cover global, static and extern funcs 2020-01-10 09:06:31 -08:00
offset-reloc-pointer-1.ll
offset-reloc-pointer-2.ll
offset-reloc-struct-anonymous.ll [BPF] extend BTF_KIND_FUNC to cover global, static and extern funcs 2020-01-10 09:06:31 -08:00
offset-reloc-struct-array.ll [BPF] extend BTF_KIND_FUNC to cover global, static and extern funcs 2020-01-10 09:06:31 -08:00
offset-reloc-typedef-array.ll
offset-reloc-typedef-struct-2.ll [BPF] handle typedef of struct/union for CO-RE relocations 2020-02-04 08:53:03 -08:00
offset-reloc-typedef-struct.ll
offset-reloc-typedef-union-2.ll [BPF] handle typedef of struct/union for CO-RE relocations 2020-02-04 08:53:03 -08:00
offset-reloc-typedef-union.ll
offset-reloc-typedef.ll
offset-reloc-union.ll [BPF] extend BTF_KIND_FUNC to cover global, static and extern funcs 2020-01-10 09:06:31 -08:00
store-addr.ll BPF: fix a CORE optimization bug 2020-04-20 19:54:51 -07:00