[cfe-commits] r102377 - in /cfe/trunk: lib/CodeGen/CGDeclCXX.cpp test/CodeGenCXX/arm.cpp
Chris Lattner
sabre at nondot.org
Mon Apr 26 13:35:54 PDT 2010
Author: lattner
Date: Mon Apr 26 15:35:54 2010
New Revision: 102377
URL: http://llvm.org/viewvc/llvm-project?rev=102377&view=rev
Log:
emit dtors with the right calling convention in -fno-use-cxa-atexit
mode.
Added:
cfe/trunk/test/CodeGenCXX/arm.cpp
Modified:
cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
Modified: cfe/trunk/lib/CodeGen/CGDeclCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGDeclCXX.cpp?rev=102377&r1=102376&r2=102377&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGDeclCXX.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGDeclCXX.cpp Mon Apr 26 15:35:54 2010
@@ -219,9 +219,14 @@
SourceLocation());
// Emit the dtors, in reverse order from construction.
- for (unsigned i = 0, e = DtorsAndObjects.size(); i != e; ++i)
- Builder.CreateCall(DtorsAndObjects[e - i - 1].first,
- DtorsAndObjects[e - i - 1].second);
+ for (unsigned i = 0, e = DtorsAndObjects.size(); i != e; ++i) {
+ llvm::Constant *Callee = DtorsAndObjects[e - i - 1].first;
+ llvm::CallInst *CI = Builder.CreateCall(Callee,
+ DtorsAndObjects[e - i - 1].second);
+ // Make sure the call and the callee agree on calling convention.
+ if (llvm::Function *F = dyn_cast<llvm::Function>(Callee))
+ CI->setCallingConv(F->getCallingConv());
+ }
FinishFunction();
}
Added: cfe/trunk/test/CodeGenCXX/arm.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/arm.cpp?rev=102377&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/arm.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/arm.cpp Mon Apr 26 15:35:54 2010
@@ -0,0 +1,20 @@
+// RUN: %clang_cc1 %s -triple=thumbv7-apple-darwin3.0.0-iphoneos -fno-use-cxa-atexit -target-abi apcs-gnu -emit-llvm -o - | FileCheck %s
+
+class foo {
+public:
+ foo();
+ virtual ~foo();
+};
+
+class bar : public foo {
+public:
+ bar();
+};
+
+// The global dtor needs the right calling conv with -fno-use-cxa-atexit
+// rdar://7817590
+bar baz;
+
+// CHECK: @_GLOBAL__D_a()
+// CHECK: call arm_apcscc void @_ZN3barD1Ev(%class.bar* @baz)
+
More information about the cfe-commits
mailing list