[PATCH] D137067: [DebugInfo][Metadata] Make AllEnumTypes holding TrackingMDNodeRef
Kristina Bessonova via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Oct 31 11:17:56 PDT 2022
krisb updated this revision to Diff 472079.
krisb added a comment.
Apply review comments.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D137067/new/
https://reviews.llvm.org/D137067
Files:
clang/test/CodeGenCXX/debug-info-enum-metadata-collision.cpp
llvm/include/llvm/IR/DIBuilder.h
llvm/lib/IR/DIBuilder.cpp
Index: llvm/lib/IR/DIBuilder.cpp
===================================================================
--- llvm/lib/IR/DIBuilder.cpp
+++ llvm/lib/IR/DIBuilder.cpp
@@ -84,7 +84,9 @@
}
if (!AllEnumTypes.empty())
- CUNode->replaceEnumTypes(MDTuple::get(VMContext, AllEnumTypes));
+ CUNode->replaceEnumTypes(MDTuple::get(
+ VMContext, SmallVector<Metadata *, 16>(AllEnumTypes.begin(),
+ AllEnumTypes.end())));
SmallVector<Metadata *, 16> RetainValues;
// Declarations and definitions of the same type may be retained. Some
@@ -556,7 +558,7 @@
getNonCompileUnitScope(Scope), UnderlyingType, SizeInBits, AlignInBits, 0,
IsScoped ? DINode::FlagEnumClass : DINode::FlagZero, Elements, 0, nullptr,
nullptr, UniqueIdentifier);
- AllEnumTypes.push_back(CTy);
+ AllEnumTypes.emplace_back(CTy);
trackIfUnresolved(CTy);
return CTy;
}
Index: llvm/include/llvm/IR/DIBuilder.h
===================================================================
--- llvm/include/llvm/IR/DIBuilder.h
+++ llvm/include/llvm/IR/DIBuilder.h
@@ -48,7 +48,7 @@
Function *LabelFn; ///< llvm.dbg.label
Function *AddrFn; ///< llvm.dbg.addr
- SmallVector<Metadata *, 4> AllEnumTypes;
+ SmallVector<TrackingMDNodeRef, 4> AllEnumTypes;
/// Track the RetainTypes, since they can be updated later on.
SmallVector<TrackingMDNodeRef, 4> AllRetainTypes;
SmallVector<Metadata *, 4> AllSubprograms;
Index: clang/test/CodeGenCXX/debug-info-enum-metadata-collision.cpp
===================================================================
--- /dev/null
+++ clang/test/CodeGenCXX/debug-info-enum-metadata-collision.cpp
@@ -0,0 +1,25 @@
+// RUN: %clang_cc1 -triple %itanium_abi_triple -emit-llvm -debug-info-kind=constructor %s -o - | FileCheck %s
+
+// Test that clang doesn't crash while resolving temporary debug metadata of
+// a record with collisions in the record's enum users.
+
+// CHECK: !DICompositeType(tag: DW_TAG_enumeration_type,
+// CHECK-SAME: scope: [[SCOPE:![0-9]+]]
+// CHECK-SAME: elements: [[ELEMENTS:![0-9]+]]
+// CHECK: [[SCOPE]] = !DICompositeType(tag: DW_TAG_structure_type
+// CHECK-SAME: name: "Struct1<Struct3>"
+// CHECK: [[ELEMENTS]] = !{[[ELEMENT:![0-9]+]]}
+// CHECK: [[ELEMENT]] = !DIEnumerator(name: "enumValue1"
+
+template <typename> struct Struct1 {
+ enum { enumValue1 };
+ Struct1();
+};
+void function2() {
+ struct Struct3 {};
+ int i = Struct1<Struct3>::enumValue1;
+}
+void function3() {
+ struct Struct3 {};
+ int i = Struct1<Struct3>::enumValue1;
+}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D137067.472079.patch
Type: text/x-patch
Size: 2674 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221031/f6349a5f/attachment.bin>
More information about the llvm-commits
mailing list