diff options
author | Yonghong Song <yhs@fb.com> | 2019-07-25 21:47:27 +0000 |
---|---|---|
committer | Yonghong Song <yhs@fb.com> | 2019-07-25 21:47:27 +0000 |
commit | 329abf29399825ce84eba81c85bed85e17e7468a (patch) | |
tree | 74a0dc0b299ecc15ff671ee894f811da56fcc9bf /llvm/lib/Target/BPF/BTFDebug.h | |
parent | b680422ef809942767cb0bfec4f00af197c3d2c4 (diff) | |
download | bcm5719-llvm-329abf29399825ce84eba81c85bed85e17e7468a.tar.gz bcm5719-llvm-329abf29399825ce84eba81c85bed85e17e7468a.zip |
[BPF] fix typedef issue for offset relocation
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.
Signed-off-by: Yonghong Song <yhs@fb.com>
Differential Revision: https://reviews.llvm.org/D65259
llvm-svn: 367062
Diffstat (limited to 'llvm/lib/Target/BPF/BTFDebug.h')
-rw-r--r-- | llvm/lib/Target/BPF/BTFDebug.h | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Target/BPF/BTFDebug.h b/llvm/lib/Target/BPF/BTFDebug.h index 6c0cdde17d9..e210d18f941 100644 --- a/llvm/lib/Target/BPF/BTFDebug.h +++ b/llvm/lib/Target/BPF/BTFDebug.h @@ -104,11 +104,14 @@ public: /// Handle array type. class BTFTypeArray : public BTFTypeBase { + const DIType *ElemTyNoQual; uint32_t ElemSize; struct BTF::BTFArray ArrayInfo; + uint32_t ElemTypeNoQual; public: - BTFTypeArray(uint32_t ElemTypeId, uint32_t ElemSize, uint32_t NumElems); + BTFTypeArray(const DIType *Ty, uint32_t ElemTypeId, + uint32_t ElemSize, uint32_t NumElems); uint32_t getSize() { return BTFTypeBase::getSize() + BTF::BTFArraySize; } void completeType(BTFDebug &BDebug); void emitType(MCStreamer &OS); @@ -120,6 +123,7 @@ class BTFTypeStruct : public BTFTypeBase { const DICompositeType *STy; bool HasBitField; std::vector<struct BTF::BTFMember> Members; + std::vector<uint32_t> MemberTypeNoQual; public: BTFTypeStruct(const DICompositeType *STy, bool IsStruct, bool HasBitField, |