Hi rafael,

The assertion failure will be raised by TryEmitDefinitionAsAlias()
because it will call Entry->replaceAllUsesWith(Alias) and Entry
might be hold by the AssertingVH, which will become a dangling
pointer after RAUW.

This commit fixes the problem by replacing AssertingVH with
TrackingVH.

Note: This issue is partially fixed by r217874, since the usage of
GetAddrOfGlobal() is replaced by getAddrOfCXXStructor() with DontDefer=true.

http://reviews.llvm.org/D5743

Files:
  lib/CodeGen/CodeGenModule.h
  test/CodeGenCXX/ctor-dtor-alias-assertingvh.cpp
Index: lib/CodeGen/CodeGenModule.h
===================================================================
--- lib/CodeGen/CodeGenModule.h
+++ lib/CodeGen/CodeGenModule.h
@@ -320,7 +320,7 @@
   /// referenced. These get code generated when the module is done.
   struct DeferredGlobal {
     DeferredGlobal(llvm::GlobalValue *GV, GlobalDecl GD) : GV(GV), GD(GD) {}
-    llvm::AssertingVH<llvm::GlobalValue> GV;
+    llvm::TrackingVH<llvm::GlobalValue> GV;
     GlobalDecl GD;
   };
   std::vector<DeferredGlobal> DeferredDeclsToEmit;
Index: test/CodeGenCXX/ctor-dtor-alias-assertingvh.cpp
===================================================================
--- /dev/null
+++ test/CodeGenCXX/ctor-dtor-alias-assertingvh.cpp
@@ -0,0 +1,24 @@
+// RUN: %clang_cc1 %s -triple i686-linux -O1 -mconstructor-aliases -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-ITANIUM
+// RUN: %clang_cc1 %s -triple i386-pc-win32 -O1 -mconstructor-aliases -emit-llvm -o - | FileCheck %s --check-prefix=CHECK-MSVC
+
+namespace ns {
+  struct Base {
+    virtual ~Base();
+  };
+
+  Base::~Base() { }
+
+  template<typename T>
+  struct Template {
+    struct NestedDerived : public Base {
+      virtual ~NestedDerived() { }
+    };
+  };
+}
+
+namespace ns {
+  template class Template<int>;
+  // CHECK-ITANIUM: $_ZN2ns8TemplateIiE13NestedDerivedD5Ev = comdat any
+  // CHECK-MSVC: @"\01??1NestedDerived@?$Template@H@ns@@UAE@XZ" = weak_odr alias bitcast (void (%"struct.ns::Base"*)* @"\01??1Base@ns@@UAE@XZ" to void (%"struct.ns::Template<int>::NestedDerived"*)*)
+
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to