Hi timurrrr,

Now that -mconstructor-aliases works for linkonce functions, we should
use aliases instead.  This makes our code less consistent with MSVC's
code, but that was never really a goal.

http://llvm-reviews.chandlerc.com/D1872

Files:
  lib/CodeGen/CGCXX.cpp
  test/CodeGenCXX/microsoft-abi-exceptions.cpp
  test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
  test/CodeGenCXX/microsoft-abi-static-initializers.cpp
  test/CodeGenCXX/microsoft-abi-structors.cpp
Index: lib/CodeGen/CGCXX.cpp
===================================================================
--- lib/CodeGen/CGCXX.cpp
+++ lib/CodeGen/CGCXX.cpp
@@ -234,15 +234,6 @@
                                       CXXDtorType dtorType,
                                       const CGFunctionInfo *fnInfo,
                                       llvm::FunctionType *fnType) {
-  // If the class has no virtual bases, then the complete and base destructors
-  // are equivalent, for all C++ ABIs supported by clang.  We can save on code
-  // size by calling the base dtor directly, especially if we'd have to emit a
-  // thunk otherwise.
-  // FIXME: We should do this for Itanium, after verifying that nothing breaks.
-  if (dtorType == Dtor_Complete && dtor->getParent()->getNumVBases() == 0 &&
-      getCXXABI().useThunkForDtorVariant(dtor, Dtor_Complete))
-    dtorType = Dtor_Base;
-
   GlobalDecl GD(dtor, dtorType);
 
   StringRef name = getMangledName(GD);
Index: test/CodeGenCXX/microsoft-abi-exceptions.cpp
===================================================================
--- test/CodeGenCXX/microsoft-abi-exceptions.cpp
+++ test/CodeGenCXX/microsoft-abi-exceptions.cpp
@@ -24,7 +24,7 @@
 // WIN32:   ret void
 //
 //    There should be one dtor call for unwinding from the second getA.
-// WIN32:   invoke x86_thiscallcc void @"\01??1A@@QAE@XZ"
+// WIN32:   invoke x86_thiscallcc void @"\01??_DA@@QAE@XZ"
 // WIN32: }
 
 void TakeRef(const A &a);
@@ -44,14 +44,14 @@
 // WIN32:   store i1 false, i1* %[[isactive]]
 // WIN32:   invoke i32 @"\01?TakesTwo@@YAHUA@@0@Z"
 //        Destroy the two const ref temporaries.
-// WIN32:   invoke x86_thiscallcc void @"\01??1A@@QAE@XZ"
-// WIN32:   call x86_thiscallcc void @"\01??1A@@QAE@XZ"
+// WIN32:   invoke x86_thiscallcc void @"\01??_DA@@QAE@XZ"
+// WIN32:   call x86_thiscallcc void @"\01??_DA@@QAE@XZ"
 // WIN32:   ret i32
 //
 //        Conditionally destroy arg1.
 // WIN32:   %[[cond:.*]] = load i1* %[[isactive]]
 // WIN32:   br i1 %[[cond]]
-// WIN32:   invoke x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A* %[[arg1]])
+// WIN32:   invoke x86_thiscallcc void @"\01??_DA@@QAE@XZ"(%struct.A* %[[arg1]])
 // WIN32: }
 
 // Test putting the cleanups inside a conditional.
@@ -73,7 +73,7 @@
 //        Still no cleanups, so call.
 // WIN32:   call i32 @"\01?CouldThrow@@YAHXZ"()
 //        Somewhere in the landing pad for our single invoke, call the dtor.
-// WIN32:   invoke x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A* %[[arg1]])
+// WIN32:   invoke x86_thiscallcc void @"\01??_DA@@QAE@XZ"(%struct.A* %[[arg1]])
 // WIN32: }
 
 // Now test both.
@@ -107,12 +107,12 @@
 //        False condition.
 // WIN32:   invoke i32 @"\01?CouldThrow@@YAHXZ"()
 //        Two normal cleanups for TakeRef args.
-// WIN32:   invoke x86_thiscallcc void @"\01??1A@@QAE@XZ"
-// WIN32:   call x86_thiscallcc void @"\01??1A@@QAE@XZ"
+// WIN32:   invoke x86_thiscallcc void @"\01??_DA@@QAE@XZ"
+// WIN32:   call x86_thiscallcc void @"\01??_DA@@QAE@XZ"
 // WIN32:   ret i32
 //
 //        Somewhere in the landing pad soup, we conditionally destroy arg1.
 // WIN32:   %[[isactive:.*]] = load i1* %[[arg1_cond]]
 // WIN32:   br i1 %[[isactive]]
-// WIN32:   invoke x86_thiscallcc void @"\01??1A@@QAE@XZ"(%struct.A* %[[arg1]])
+// WIN32:   invoke x86_thiscallcc void @"\01??_DA@@QAE@XZ"(%struct.A* %[[arg1]])
 // WIN32: }
Index: test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
===================================================================
--- test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
+++ test/CodeGenCXX/microsoft-abi-sret-and-byval.cpp
@@ -1,6 +1,9 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-linux | FileCheck -check-prefix LINUX %s
-// RUN: not %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -cxx-abi microsoft | FileCheck -check-prefix WIN32 %s
-// RUN: not %clang_cc1 -emit-llvm %s -o - -triple=x86_64-pc-win32 -cxx-abi microsoft | FileCheck -check-prefix WIN64 %s
+// RUN: %clang_cc1 -fno-rtti -mconstructor-aliases -emit-llvm %s -o - -triple=i386-pc-linux | FileCheck -check-prefix LINUX %s
+// RUN: %clang_cc1 -fno-rtti -mconstructor-aliases -emit-llvm %s -o - -triple=i386-pc-win32 -cxx-abi microsoft | FileCheck -check-prefix WIN32 %s
+// RUN: %clang_cc1 -fno-rtti -mconstructor-aliases -emit-llvm %s -o - -triple=x86_64-pc-win32 -cxx-abi microsoft | FileCheck -check-prefix WIN64 %s
+
+// WIN32: @"\01??_DX@@QAE@XZ" = alias linkonce_odr void (%struct.X*)* @"\01??1X@@QAE@XZ"
+// WIN32: @"\01??_DSmallWithDtor@@QAE@XZ" = alias linkonce_odr void (%struct.SmallWithDtor*)* @"\01??1SmallWithDtor@@QAE@XZ"
 
 struct Empty {};
 
@@ -104,10 +107,10 @@
 // Test that dtors are invoked in the callee.
 void small_arg_with_dtor(SmallWithDtor s) {}
 // WIN32: define void @"\01?small_arg_with_dtor@@YAXUSmallWithDtor@@@Z"(%struct.SmallWithDtor* byval align 4 %s) {{.*}} {
-// WIN32:   call x86_thiscallcc void @"\01??1SmallWithDtor@@QAE@XZ"(%struct.SmallWithDtor* %s)
+// WIN32:   call x86_thiscallcc void @"\01??_DSmallWithDtor@@QAE@XZ"(%struct.SmallWithDtor* %s)
 // WIN32: }
 // WIN64: define void @"\01?small_arg_with_dtor@@YAXUSmallWithDtor@@@Z"(%struct.SmallWithDtor* byval %s) {{.*}} {
-// WIN64:   call void @"\01??1SmallWithDtor@@QEAA@XZ"(%struct.SmallWithDtor* %s)
+// WIN64:   call void @"\01??_DSmallWithDtor@@QEAA@XZ"(%struct.SmallWithDtor* %s)
 // WIN64: }
 
 // Test that references aren't destroyed in the callee.
@@ -123,7 +126,7 @@
 // WIN32: define void @"\01?temporary_ref_with_dtor@@YAXXZ"() {{.*}} {
 // WIN32:   call x86_thiscallcc %struct.SmallWithDtor* @"\01??0SmallWithDtor@@QAE@XZ"
 // WIN32:   call void @"\01?ref_small_arg_with_dtor@@YAXABUSmallWithDtor@@@Z"
-// WIN32:   call x86_thiscallcc void @"\01??1SmallWithDtor@@QAE@XZ"
+// WIN32:   call x86_thiscallcc void @"\01??_DSmallWithDtor@@QAE@XZ"
 // WIN32: }
 
 void takes_two_by_val_with_dtor(SmallWithDtor a, SmallWithDtor b);
@@ -136,7 +139,7 @@
 // WIN32:   call x86_thiscallcc %struct.SmallWithDtor* @"\01??0SmallWithDtor@@QAE@XZ"
 // WIN32:   call x86_thiscallcc %struct.SmallWithDtor* @"\01??0SmallWithDtor@@QAE@XZ"
 // WIN32:   call void @"\01?takes_two_by_val_with_dtor@@YAXUSmallWithDtor@@0@Z"
-// WIN32-NOT: call x86_thiscallcc void @"\01??1SmallWithDtor@@QAE@XZ"
+// WIN32-NOT: call x86_thiscallcc void @"\01??_DSmallWithDtor@@QAE@XZ"
 // WIN32: }
 
 void small_arg_with_vftable(SmallWithVftable s) {}
@@ -219,7 +222,7 @@
 void g(X) {
 }
 // WIN32: define void @"\01?g@@YAXUX@@@Z"(%struct.X* byval align 4) {{.*}} {
-// WIN32:   call x86_thiscallcc void @"\01??1X@@QAE@XZ"(%struct.X* %0)
+// WIN32:   call x86_thiscallcc void @"\01??_DX@@QAE@XZ"(%struct.X* %0)
 // WIN32: }
 void f() {
   g(X());
Index: test/CodeGenCXX/microsoft-abi-static-initializers.cpp
===================================================================
--- test/CodeGenCXX/microsoft-abi-static-initializers.cpp
+++ test/CodeGenCXX/microsoft-abi-static-initializers.cpp
@@ -17,7 +17,7 @@
 // CHECK: ret void
 
 // CHECK: define internal void @"\01??__Fs@@YAXXZ"() [[NUW]] {
-// CHECK: call x86_thiscallcc void @"\01??1S@@QAE@XZ"
+// CHECK: call x86_thiscallcc void @"\01??_DS@@QAE@XZ"
 // CHECK: ret void
 
 void StaticLocal() {
@@ -141,10 +141,10 @@
 
 // CHECK: define linkonce_odr x86_thiscallcc %class.A* @"\01??0A@@QAE@XZ"
 
-// CHECK: define linkonce_odr x86_thiscallcc void @"\01??1A@@QAE@XZ"
+// CHECK: define linkonce_odr x86_thiscallcc void @"\01??_DA@@QAE@XZ"
 
 // CHECK: define internal void @"\01??__Ffoo@?$B@H@@YAXXZ"
-// CHECK: call x86_thiscallcc void @"\01??1A@@QAE@XZ"{{.*}}foo
+// CHECK: call x86_thiscallcc void @"\01??_DA@@QAE@XZ"{{.*}}foo
 // CHECK: ret void
 
 // CHECK: define internal void @_GLOBAL__I_a() [[NUW]] {
Index: test/CodeGenCXX/microsoft-abi-structors.cpp
===================================================================
--- test/CodeGenCXX/microsoft-abi-structors.cpp
+++ test/CodeGenCXX/microsoft-abi-structors.cpp
@@ -3,6 +3,7 @@
 // vftables are emitted very late, so do another pass to try to keep the checks
 // in source order.
 // RUN: FileCheck --check-prefix DTORS %s < %t
+// RUN: FileCheck --check-prefix MANGLING %s < %t
 //
 // RUN: %clang_cc1 -emit-llvm %s -o - -cxx-abi microsoft -triple=x86_64-pc-win32 -fno-rtti | FileCheck --check-prefix DTORS-X64 %s
 
@@ -47,7 +48,7 @@
 // DTORS:      define linkonce_odr x86_thiscallcc void @"\01??_GC@basic@@UAEPAXI@Z"(%"struct.basic::C"* %this, i32 %should_call_delete)
 // DTORS:        store i32 %should_call_delete, i32* %[[SHOULD_DELETE_VAR:[0-9a-z._]+]], align 4
 // DTORS:        %[[SHOULD_DELETE_VALUE:[0-9a-z._]+]] = load i32* %[[SHOULD_DELETE_VAR]]
-// DTORS:        call x86_thiscallcc void @"\01??1C@basic@@UAE@XZ"(%"struct.basic::C"* %[[THIS:[0-9a-z]+]])
+// DTORS:        call x86_thiscallcc void @"\01??_DC@basic@@UAE@XZ"(%"struct.basic::C"* %[[THIS:[0-9a-z]+]])
 // DTORS-NEXT:   %[[CONDITION:[0-9]+]] = icmp eq i32 %[[SHOULD_DELETE_VALUE]], 0
 // DTORS-NEXT:   br i1 %[[CONDITION]], label %[[CONTINUE_LABEL:[0-9a-z._]+]], label %[[CALL_DELETE_LABEL:[0-9a-z._]+]]
 //
@@ -108,12 +109,12 @@
   D() {
     static int ctor_static = foo();
     // CHECK that the static in the ctor gets mangled correctly:
-    // CHECK: @"\01?ctor_static@?1???0D@basic@@QAE@XZ@4HA"
+    // MANGLING: @"\01?ctor_static@?1???0D@basic@@QAE@XZ@4HA"
   }
   ~D() {
     static int dtor_static = foo();
     // CHECK that the static in the dtor gets mangled correctly:
-    // CHECK: @"\01?dtor_static@?1???1D@basic@@QAE@XZ@4HA"
+    // MANGLING: @"\01?dtor_static@?1???1D@basic@@QAE@XZ@4HA"
   }
 };
 
@@ -250,8 +251,6 @@
 // CHECK: ret
 }
 
-// CHECK: declare x86_thiscallcc void @"\01??1A@dtors@@QAE@XZ"
-
 // Now try some virtual bases, where we need the complete dtor.
 
 struct B : virtual A { ~B(); };
@@ -292,4 +291,17 @@
 // CHECK: ret
 }
 
+// CHECK: declare x86_thiscallcc void @"\01??1A@dtors@@QAE@XZ"
+
+}
+
+namespace PR17514 {
+struct C {
+  virtual ~C();
+};
+struct F : C {};
+void fn1() {
+  F first;
+  first.~F();
+}
 }
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to