r200711 - [ms-cxxabi] Fix cast when structor replacement is an alias
Reid Kleckner
reid at kleckner.net
Mon Feb 3 10:54:51 PST 2014
Author: rnk
Date: Mon Feb 3 12:54:51 2014
New Revision: 200711
URL: http://llvm.org/viewvc/llvm-project?rev=200711&view=rev
Log:
[ms-cxxabi] Fix cast when structor replacement is an alias
Modified:
cfe/trunk/lib/CodeGen/CodeGenModule.cpp
cfe/trunk/test/CodeGenCXX/destructors.cpp
cfe/trunk/test/CodeGenCXX/microsoft-abi-structors-alias.cpp
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=200711&r1=200710&r2=200711&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Mon Feb 3 12:54:51 2014
@@ -187,10 +187,14 @@ void CodeGenModule::applyReplacements()
llvm::Function *OldF = cast<llvm::Function>(Entry);
llvm::Function *NewF = dyn_cast<llvm::Function>(Replacement);
if (!NewF) {
- llvm::ConstantExpr *CE = cast<llvm::ConstantExpr>(Replacement);
- assert(CE->getOpcode() == llvm::Instruction::BitCast ||
- CE->getOpcode() == llvm::Instruction::GetElementPtr);
- NewF = dyn_cast<llvm::Function>(CE->getOperand(0));
+ if (llvm::GlobalAlias *Alias = dyn_cast<llvm::GlobalAlias>(Replacement)) {
+ NewF = dyn_cast<llvm::Function>(Alias->getAliasedGlobal());
+ } else {
+ llvm::ConstantExpr *CE = cast<llvm::ConstantExpr>(Replacement);
+ assert(CE->getOpcode() == llvm::Instruction::BitCast ||
+ CE->getOpcode() == llvm::Instruction::GetElementPtr);
+ NewF = dyn_cast<llvm::Function>(CE->getOperand(0));
+ }
}
// Replace old with new, but keep the old order.
Modified: cfe/trunk/test/CodeGenCXX/destructors.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/destructors.cpp?rev=200711&r1=200710&r2=200711&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/destructors.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/destructors.cpp Mon Feb 3 12:54:51 2014
@@ -6,6 +6,13 @@
// CHECK-DAG: @_ZN5test11OD2Ev = alias {{.*}} @_ZN5test11AD2Ev
// CHECK-DAG: @_ZN5test11SD2Ev = alias bitcast {{.*}} @_ZN5test11AD2Ev
+// WIN32-DAG: @_ZN5test01AD1Ev = alias {{.*}} @_ZN5test01AD2Ev
+// WIN32-DAG: @_ZN5test11MD2Ev = alias {{.*}} @_ZN5test11AD2Ev
+// WIN32-DAG: @_ZN5test11ND2Ev = alias {{.*}} @_ZN5test11AD2Ev
+// WIN32-DAG: @_ZN5test11OD2Ev = alias {{.*}} @_ZN5test11AD2Ev
+// WIN32-DAG: @_ZN5test11SD2Ev = alias bitcast {{.*}} @_ZN5test11AD2Ev
+
+
struct A {
int a;
Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-structors-alias.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-structors-alias.cpp?rev=200711&r1=200710&r2=200711&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-structors-alias.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-structors-alias.cpp Mon Feb 3 12:54:51 2014
@@ -1,9 +1,26 @@
-// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -fno-rtti -mconstructor-aliases | FileCheck %s
+// RUN: %clang_cc1 -emit-llvm %s -o - -triple=i386-pc-win32 -fno-rtti -mconstructor-aliases -O1 -disable-llvm-optzns | FileCheck %s
namespace test1 {
template <typename T> class A {
~A() {}
};
template class A<char>;
-// CHECK: define weak_odr x86_thiscallcc void @"\01??1?$A at D@test1@@AAE at XZ"
+// CHECK-DAG: define weak_odr x86_thiscallcc void @"\01??1?$A at D@test1@@AAE at XZ"
+}
+
+namespace test2 {
+struct A {
+ virtual ~A();
+};
+struct B : A {
+ B();
+ virtual ~B();
+};
+
+A::~A() {}
+B::~B() {}
+void foo() {
+ B b;
+}
+// CHECK-DAG: @"\01??1B at test2@@UAE at XZ" = alias bitcast (void (%"struct.test2::A"*)* @"\01??1A at test2@@UAE at XZ" to void (%"struct.test2::B"*)*)
}
More information about the cfe-commits
mailing list