probinson created this revision.
Make sure all temporary MD nodes have been replaced with uniqued or distinct
nodes before we clone a function.
Fixes PR33930.
https://reviews.llvm.org/D37038
Files:
lib/CodeGen/CGDebugInfo.cpp
lib/CodeGen/CGDebugInfo.h
lib/CodeGen/CGVTables.cpp
test/CodeGenCXX/temp-md-nodes1.cpp
test/CodeGenCXX/temp-md-nodes2.cpp
Index: test/CodeGenCXX/temp-md-nodes2.cpp
===================================================================
--- test/CodeGenCXX/temp-md-nodes2.cpp
+++ test/CodeGenCXX/temp-md-nodes2.cpp
@@ -0,0 +1,33 @@
+// REQUIRES: asserts
+// RUN: %clang_cc1 -O0 -triple %itanium_abi_triple -debug-info-kind=limited -S -emit-llvm %s -o - | \
+// RUN: FileCheck %s
+
+// This test simply checks that the varargs thunk is created. The failing test
+// case asserts.
+
+typedef signed char __int8_t;
+typedef int BOOL;
+class CMsgAgent;
+
+class CFs {
+public:
+ typedef enum {} CACHE_HINT;
+ virtual BOOL ReqCacheHint( CMsgAgent* p_ma, CACHE_HINT hint, ... ) ;
+};
+
+typedef struct {} _Lldiv_t;
+
+class CBdVfs {
+public:
+ virtual ~CBdVfs( ) {}
+};
+
+class CBdVfsImpl : public CBdVfs, public CFs {
+ BOOL ReqCacheHint( CMsgAgent* p_ma, CACHE_HINT hint, ... );
+};
+
+BOOL CBdVfsImpl::ReqCacheHint( CMsgAgent* p_ma, CACHE_HINT hint, ... ) {
+ return true;
+}
+
+// CHECK: define {{.*}} @_ZThn8_N10CBdVfsImpl12ReqCacheHintEP9CMsgAgentN3CFs10CACHE_HINTEz(
Index: test/CodeGenCXX/temp-md-nodes1.cpp
===================================================================
--- test/CodeGenCXX/temp-md-nodes1.cpp
+++ test/CodeGenCXX/temp-md-nodes1.cpp
@@ -0,0 +1,18 @@
+// REQUIRES: asserts
+// RUN: %clang_cc1 -O0 -triple %itanium_abi_triple -debug-info-kind=limited -S -emit-llvm %s -o - | \
+// RUN: FileCheck %s
+
+// This test simply checks that the varargs thunk is created. The failing test
+// case asserts.
+
+struct Alpha {
+ virtual void bravo(...);
+};
+struct Charlie {
+ virtual ~Charlie() {}
+};
+struct CharlieImpl : Charlie, Alpha {
+ void bravo(...) {}
+} delta;
+
+// CHECK: define {{.*}} void @_ZThn8_N11CharlieImpl5bravoEz(
Index: lib/CodeGen/CGVTables.cpp
===================================================================
--- lib/CodeGen/CGVTables.cpp
+++ lib/CodeGen/CGVTables.cpp
@@ -152,6 +152,10 @@
llvm::Value *Callee = CGM.GetAddrOfFunction(GD, Ty, /*ForVTable=*/true);
llvm::Function *BaseFn = cast<llvm::Function>(Callee);
+ // Ensure we don't have any temporary MD nodes before we clone the function.
+ if (DebugInfo)
+ DebugInfo->replaceTemporaryNodes();
+
// Clone to thunk.
llvm::ValueToValueMapTy VMap;
llvm::Function *NewFn = llvm::CloneFunction(BaseFn, VMap);
Index: lib/CodeGen/CGDebugInfo.h
===================================================================
--- lib/CodeGen/CGDebugInfo.h
+++ lib/CodeGen/CGDebugInfo.h
@@ -440,6 +440,7 @@
void completeTemplateDefinition(const ClassTemplateSpecializationDecl &SD);
void completeUnusedClass(const CXXRecordDecl &D);
+ void replaceTemporaryNodes();
/// Create debug info for a macro defined by a #define directive or a macro
/// undefined by a #undef directive.
Index: lib/CodeGen/CGDebugInfo.cpp
===================================================================
--- lib/CodeGen/CGDebugInfo.cpp
+++ lib/CodeGen/CGDebugInfo.cpp
@@ -4091,18 +4091,7 @@
TheCU->setDWOId(Signature);
}
-
-void CGDebugInfo::finalize() {
- // Creating types might create further types - invalidating the current
- // element and the size(), so don't cache/reference them.
- for (size_t i = 0; i != ObjCInterfaceCache.size(); ++i) {
- ObjCInterfaceCacheEntry E = ObjCInterfaceCache[i];
- llvm::DIType *Ty = E.Type->getDecl()->getDefinition()
- ? CreateTypeDefinition(E.Type, E.Unit)
- : E.Decl;
- DBuilder.replaceTemporary(llvm::TempDIType(E.Decl), Ty);
- }
-
+void CGDebugInfo::replaceTemporaryNodes() {
for (auto p : ReplaceMap) {
assert(p.second);
auto *Ty = cast<llvm::DIType>(p.second);
@@ -4115,6 +4104,21 @@
DBuilder.replaceTemporary(llvm::TempDIType(Ty),
cast<llvm::DIType>(it->second));
}
+ ReplaceMap.clear();
+}
+
+void CGDebugInfo::finalize() {
+ // Creating types might create further types - invalidating the current
+ // element and the size(), so don't cache/reference them.
+ for (size_t i = 0; i != ObjCInterfaceCache.size(); ++i) {
+ ObjCInterfaceCacheEntry E = ObjCInterfaceCache[i];
+ llvm::DIType *Ty = E.Type->getDecl()->getDefinition()
+ ? CreateTypeDefinition(E.Type, E.Unit)
+ : E.Decl;
+ DBuilder.replaceTemporary(llvm::TempDIType(E.Decl), Ty);
+ }
+
+ replaceTemporaryNodes();
for (const auto &p : FwdDeclReplaceMap) {
assert(p.second);
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits