llvm-project/llvm/test/CodeGen/BPF
Yonghong Song ac2e25026f bpf: avoid load from read-only sections
If users tried to have a structure decl/init code like below
   struct test_t t = { .memeber1 = 45 };
It is very likely that compiler will generate a readonly section
to hold up the init values for variable t. Later load of t members,
e.g., t.member1 will result in a read from readonly section.

BPF program cannot handle relocation. This will force users to
write:
  struct test_t t = {};
  t.member1 = 45;
This is just inconvenient and unintuitive.

This patch addresses this issue by implementing BPF PreprocessISelDAG.
For any load from a global constant structure or an global array of
constant struct, it attempts to
translate it into a constant directly. The traversal of the
constant struct and other constant data structures are similar
to where the assembler emits read-only sections.

Four different unit test cases are also added to cover
different scenarios.

Signed-off-by: Yonghong Song <yhs@fb.com>
llvm-svn: 305560
2017-06-16 15:41:16 +00:00
..
alu8.ll convert bpf assembler to look like kernel verifier output 2016-11-18 02:32:35 +00:00
atomics.ll [bpf] add BPF disassembler 2016-11-20 02:25:00 +00:00
basictest.ll convert bpf assembler to look like kernel verifier output 2016-11-18 02:32:35 +00:00
byval.ll
cc_args.ll [bpf] error when unknown bpf helper is called 2017-01-17 07:26:17 +00:00
cc_args_be.ll [bpf] error when unknown bpf helper is called 2017-01-17 07:26:17 +00:00
cc_ret.ll [bpf] error when unknown bpf helper is called 2017-01-17 07:26:17 +00:00
cmp.ll convert bpf assembler to look like kernel verifier output 2016-11-18 02:32:35 +00:00
dwarfdump.ll [bpf] fix a bug which causes incorrect big endian reloc fixup 2017-05-05 18:05:00 +00:00
ex1.ll convert bpf assembler to look like kernel verifier output 2016-11-18 02:32:35 +00:00
fi_ri.ll [bpf] error when unknown bpf helper is called 2017-01-17 07:26:17 +00:00
intrinsics.ll [bpf] error when unknown bpf helper is called 2017-01-17 07:26:17 +00:00
lit.local.cfg
load.ll convert bpf assembler to look like kernel verifier output 2016-11-18 02:32:35 +00:00
loops.ll convert bpf assembler to look like kernel verifier output 2016-11-18 02:32:35 +00:00
many_args1.ll
many_args2.ll
mem_offset.ll [bpf] Fix memory offset check for loads and stores 2017-04-13 22:24:13 +00:00
mem_offset_be.ll [bpf] add bigendian support to disassembler 2017-04-28 16:51:01 +00:00
objdump_atomics.ll [bpf] add BPF disassembler 2016-11-20 02:25:00 +00:00
objdump_intrinsics.ll [bpf] error when unknown bpf helper is called 2017-01-17 07:26:17 +00:00
objdump_trivial.ll [bpf] error when unknown bpf helper is called 2017-01-17 07:26:17 +00:00
reloc.ll [bpf] add relocation support 2017-05-03 17:30:56 +00:00
rodata_1.ll bpf: avoid load from read-only sections 2017-06-16 15:41:16 +00:00
rodata_2.ll bpf: avoid load from read-only sections 2017-06-16 15:41:16 +00:00
rodata_3.ll bpf: avoid load from read-only sections 2017-06-16 15:41:16 +00:00
rodata_4.ll bpf: avoid load from read-only sections 2017-06-16 15:41:16 +00:00
sanity.ll [bpf] error when unknown bpf helper is called 2017-01-17 07:26:17 +00:00
sdiv_error.ll
setcc.ll convert bpf assembler to look like kernel verifier output 2016-11-18 02:32:35 +00:00
shifts.ll convert bpf assembler to look like kernel verifier output 2016-11-18 02:32:35 +00:00
sockex2.ll convert bpf assembler to look like kernel verifier output 2016-11-18 02:32:35 +00:00
struct_ret1.ll
struct_ret2.ll
undef.ll In visitSTORE, always use FindBetterChain, rather than only when UseAA is enabled. 2017-03-14 00:34:14 +00:00
vararg1.ll
warn-call.ll [bpf] error when unknown bpf helper is called 2017-01-17 07:26:17 +00:00
warn-stack.ll Add address space mangling to lifetime intrinsics 2017-04-10 20:18:21 +00:00