summaryrefslogtreecommitdiff
path: root/llvm/lib/Target/BPF/BTFDebug.cpp
diff options
context:
space:
mode:
authorYonghong Song <yhs@fb.com>2020-07-01 07:51:55 -0700
committerYonghong Song <yhs@fb.com>2020-07-01 09:55:01 -0700
commit3eacfdc72f1aa3ac53eb300116f194d560053ec7 (patch)
tree083659bd73423afea36bd23bb5d885c036a3e3f8 /llvm/lib/Target/BPF/BTFDebug.cpp
parent4b0aa5724feaa89a9538dcab97e018110b0e4bc3 (diff)
[BPF] Fix a BTF gen bug related to a pointer struct member
Currently, BTF generation stops at pointer struct members if the pointee type is a struct. This is to avoid bloating generated BTF size. The following is the process to correctly record types for these pointee struct types. - During type traversal stage, when a struct member, which is a pointer to another struct, is encountered, the pointee struct type, keyed with its name, is remembered in a Fixup map. - Later, when all type traversal is done, the Fixup map is scanned, based on struct name matching, to either resolve as pointing to a real already generated type or as a forward declaration. Andrii discovered a bug if the struct member pointee struct is anonymous. In this case, a struct with empty name is recorded in Fixup map, and later it happens another anonymous struct with empty name is defined in BTF. So wrong type resolution happens. To fix the problem, if the struct member pointee struct is anonymous, pointee struct type will be generated in stead of being put in Fixup map. Differential Revision: https://reviews.llvm.org/D82976
Diffstat (limited to 'llvm/lib/Target/BPF/BTFDebug.cpp')
-rw-r--r--llvm/lib/Target/BPF/BTFDebug.cpp2
1 files changed, 1 insertions, 1 deletions
diff --git a/llvm/lib/Target/BPF/BTFDebug.cpp b/llvm/lib/Target/BPF/BTFDebug.cpp
index f0996d637d36..6ada75adba96 100644
--- a/llvm/lib/Target/BPF/BTFDebug.cpp
+++ b/llvm/lib/Target/BPF/BTFDebug.cpp
@@ -568,7 +568,7 @@ void BTFDebug::visitDerivedType(const DIDerivedType *DTy, uint32_t &TypeId,
auto CTag = CTy->getTag();
if ((CTag == dwarf::DW_TAG_structure_type ||
CTag == dwarf::DW_TAG_union_type) &&
- !CTy->isForwardDecl()) {
+ !CTy->getName().empty() && !CTy->isForwardDecl()) {
/// Find a candidate, generate a fixup. Later on the struct/union
/// pointee type will be replaced with either a real type or
/// a forward declaration.