diff options
author | Yonghong Song <yhs@fb.com> | 2017-06-16 15:41:16 +0000 |
---|---|---|
committer | Yonghong Song <yhs@fb.com> | 2017-06-16 15:41:16 +0000 |
commit | ac2e25026fa7a198c33fe521d9c02865ede12981 (patch) | |
tree | f0978fc9ca074bf6d9272805f2191408eb049d6b /clang/lib/Frontend/CompilerInvocation.cpp | |
parent | 5c6543961771fa3345b9cfd5785cfc8cde7f0a37 (diff) | |
download | llvm-ac2e25026fa7a198c33fe521d9c02865ede12981.zip llvm-ac2e25026fa7a198c33fe521d9c02865ede12981.tar.gz llvm-ac2e25026fa7a198c33fe521d9c02865ede12981.tar.bz2 |
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
Diffstat (limited to 'clang/lib/Frontend/CompilerInvocation.cpp')
0 files changed, 0 insertions, 0 deletions