[PATCH] D65259: fix typedef issue for offset relocation
Yonghong Song via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed Jul 24 19:37:36 PDT 2019
yonghong-song created this revision.
yonghong-song added a reviewer: ast.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
Currently, the CO-RE offset relocation does not work
if any struct/union member or array element is a typedef.
For example,
typedef const int arr_t[7];
struct input {
arr_t a;
};
func(...) {
struct input *in = ...;
... __builtin_preserve_access_index(&in->a[1]) ...
}
The BPF backend calculated default offset is 0 while
4 is the correct answer. Similar issues exist for struct/union
typedef's.
When getting struct/union member or array element type,
we should trace down to the type by skipping typedef
and qualifiers const/volatile as this is what clang did
to generate getelementptr instructions.
(const/volatile member type qualifiers are already
ignored by clang.)
This patch fixed this issue, for each access index,
skipping typedef and const/volatile/restrict BTF types.
Repository:
rL LLVM
https://reviews.llvm.org/D65259
Files:
lib/Target/BPF/BTFDebug.cpp
lib/Target/BPF/BTFDebug.h
test/CodeGen/BPF/CORE/offset-reloc-typedef-array.ll
test/CodeGen/BPF/CORE/offset-reloc-typedef-struct.ll
test/CodeGen/BPF/CORE/offset-reloc-typedef-union.ll
test/CodeGen/BPF/CORE/offset-reloc-typedef.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D65259.211660.patch
Type: text/x-patch
Size: 27960 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190725/f1e2dacd/attachment.bin>
More information about the llvm-commits
mailing list