Use rauw for all discardable aliases, not just linkonce_odr.
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@194296 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/CodeGen/CGCXX.cpp b/lib/CodeGen/CGCXX.cpp
index 8c7a089..f9b07d2 100644
--- a/lib/CodeGen/CGCXX.cpp
+++ b/lib/CodeGen/CGCXX.cpp
@@ -141,7 +141,7 @@
// Instead of creating as alias to a linkonce_odr, replace all of the uses
// of the aliassee.
- if (Linkage == llvm::GlobalValue::LinkOnceODRLinkage) {
+ if (llvm::GlobalValue::isDiscardableIfUnused(Linkage)) {
Replacements[MangledName] = Aliasee;
return false;
}
diff --git a/test/CodeGenCXX/ctor-dtor-alias.cpp b/test/CodeGenCXX/ctor-dtor-alias.cpp
index fdd378b..6e1c144 100644
--- a/test/CodeGenCXX/ctor-dtor-alias.cpp
+++ b/test/CodeGenCXX/ctor-dtor-alias.cpp
@@ -26,12 +26,11 @@
}
namespace test3 {
-// test that these alias are internal.
+// test that instead of an internal alias we just use the other destructor
+// directly.
-// CHECK-DAG: @_ZN5test312_GLOBAL__N_11AD1Ev = alias internal void (%"struct.test3::<anonymous namespace>::A"*)* @_ZN5test312_GLOBAL__N_11AD2Ev
-// CHECK-DAG: @_ZN5test312_GLOBAL__N_11BD2Ev = alias internal bitcast (void (%"struct.test3::<anonymous namespace>::A"*)* @_ZN5test312_GLOBAL__N_11AD2Ev to void (%"struct.test3::<anonymous namespace>::B"*)*)
-// CHECK-DAG: @_ZN5test312_GLOBAL__N_11BD1Ev = alias internal void (%"struct.test3::<anonymous namespace>::B"*)* @_ZN5test312_GLOBAL__N_11BD2Ev
// CHECK-DAG: define internal void @_ZN5test312_GLOBAL__N_11AD2Ev(
+// CHECK-DAG: call i32 @__cxa_atexit{{.*}}_ZN5test312_GLOBAL__N_11AD2Ev
namespace {
struct A {
~A() {}
@@ -58,3 +57,19 @@
};
B X;
}
+
+namespace test5 {
+ // similar to test4, but with an internal B.
+
+ // CHECK-DAG: define linkonce_odr void @_ZN5test51AD2Ev(
+ // CHECK-DAG: call i32 @__cxa_atexit{{.*}}_ZN5test51AD2Ev
+ struct A {
+ virtual ~A() {}
+ };
+ namespace {
+ struct B : public A{
+ ~B() {}
+ };
+ }
+ B X;
+}
diff --git a/test/CodeGenCXX/destructors.cpp b/test/CodeGenCXX/destructors.cpp
index b98c5c7..5b29ce5 100644
--- a/test/CodeGenCXX/destructors.cpp
+++ b/test/CodeGenCXX/destructors.cpp
@@ -6,10 +6,6 @@
// CHECK-DAG: @_ZN5test11OD2Ev = alias {{.*}} @_ZN5test11AD2Ev
// CHECK-DAG: @_ZN5test11SD2Ev = alias bitcast {{.*}} @_ZN5test11AD2Ev
-// CHECK-DAG: @_ZN5test312_GLOBAL__N_11DD1Ev = alias internal {{.*}} @_ZN5test312_GLOBAL__N_11DD2Ev
-// CHECK-DAG: @_ZN5test312_GLOBAL__N_11DD2Ev = alias internal bitcast {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev
-// CHECK-DAG: @_ZN5test312_GLOBAL__N_11CD1Ev = alias internal {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev
-
struct A {
int a;
@@ -184,12 +180,6 @@
void test() {
new D; // Force emission of D's vtable
}
-
- // Checked at top of file:
- // @_ZN5test312_GLOBAL__N_11CD1Ev = alias internal {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev
-
- // More checks at end of file.
-
}
namespace test4 {
@@ -385,7 +375,7 @@
// Checks from test3:
// CHECK-LABEL: define internal void @_ZN5test312_GLOBAL__N_11DD0Ev(%"struct.test3::<anonymous namespace>::D"* %this) unnamed_addr
- // CHECK: invoke void @_ZN5test312_GLOBAL__N_11DD1Ev(
+ // CHECK: invoke void {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev
// CHECK: call void @_ZdlPv({{.*}}) [[NUW:#[0-9]+]]
// CHECK: ret void
// CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
@@ -393,13 +383,9 @@
// CHECK: call void @_ZdlPv({{.*}}) [[NUW]]
// CHECK: resume { i8*, i32 }
- // Checked at top of file:
- // @_ZN5test312_GLOBAL__N_11DD1Ev = alias internal {{.*}} @_ZN5test312_GLOBAL__N_11DD2Ev
- // @_ZN5test312_GLOBAL__N_11DD2Ev = alias internal bitcast {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev
-
// CHECK-LABEL: define internal void @_ZThn8_N5test312_GLOBAL__N_11DD1Ev(
// CHECK: getelementptr inbounds i8* {{.*}}, i64 -8
- // CHECK: call void @_ZN5test312_GLOBAL__N_11DD1Ev(
+ // CHECK: call void {{.*}} @_ZN5test312_GLOBAL__N_11CD2Ev
// CHECK: ret void
// CHECK-LABEL: define internal void @_ZThn8_N5test312_GLOBAL__N_11DD0Ev(
@@ -414,14 +400,14 @@
// CHECK-LABEL: define internal void @_ZThn8_N5test312_GLOBAL__N_11CD1Ev(
// CHECK: getelementptr inbounds i8* {{.*}}, i64 -8
- // CHECK: call void @_ZN5test312_GLOBAL__N_11CD1Ev(
+ // CHECK: call void @_ZN5test312_GLOBAL__N_11CD2Ev(
// CHECK: ret void
// CHECK: declare void @_ZN5test31BD2Ev(
// CHECK: declare void @_ZN5test31AD2Ev(
// CHECK-LABEL: define internal void @_ZN5test312_GLOBAL__N_11CD0Ev(%"struct.test3::<anonymous namespace>::C"* %this) unnamed_addr
- // CHECK: invoke void @_ZN5test312_GLOBAL__N_11CD1Ev(
+ // CHECK: invoke void @_ZN5test312_GLOBAL__N_11CD2Ev(
// CHECK: call void @_ZdlPv({{.*}}) [[NUW]]
// CHECK: ret void
// CHECK: landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)