[cfe-commits] r124757 - in /cfe/trunk: lib/CodeGen/CGClass.cpp test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp

Fariborz Jahanian fjahanian at apple.com
Wed Feb 2 15:12:46 PST 2011


Author: fjahanian
Date: Wed Feb  2 17:12:46 2011
New Revision: 124757

URL: http://llvm.org/viewvc/llvm-project?rev=124757&view=rev
Log:
-fapple-kext, elimination of all direct calls to virtual dtors.


Added:
    cfe/trunk/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp
Modified:
    cfe/trunk/lib/CodeGen/CGClass.cpp

Modified: cfe/trunk/lib/CodeGen/CGClass.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGClass.cpp?rev=124757&r1=124756&r2=124757&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGClass.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGClass.cpp Wed Feb  2 17:12:46 2011
@@ -796,6 +796,10 @@
       assert(Dtor->isImplicit() && "bodyless dtor not implicit");
       // nothing to do besides what's in the epilogue
     }
+    // -fapple-kext must inline any call to this dtor into
+    // the caller's body.
+    if (getContext().getLangOptions().AppleKext)
+      CurFn->addFnAttr(llvm::Attribute::AlwaysInline);
     break;
   }
 

Added: cfe/trunk/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp?rev=124757&view=auto
==============================================================================
--- cfe/trunk/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp (added)
+++ cfe/trunk/test/CodeGenCXX/apple-kext-indirect-virtual-dtor-call.cpp Wed Feb  2 17:12:46 2011
@@ -0,0 +1,19 @@
+// RUN: %clang_cc1 -triple x86_64-apple-darwin10 -fapple-kext -fno-rtti -emit-llvm -o - %s | FileCheck %s
+
+// CHECK: define void @_ZN2B1D0Ev
+// CHECK: [[T1:%.*]] = load void (%struct.B1*)** getelementptr inbounds (void (%struct.B1*)** bitcast ([5 x i8*]* @_ZTV2B1 to void (%struct.B1*)**), i64 2)
+// CHECK-NEXT: call void [[T1]](%struct.B1* [[T2:%.*]])
+// CHECK: define void @_Z6DELETEP2B1
+// CHECK: [[T3:%.*]] = load void (%struct.B1*)** getelementptr inbounds (void (%struct.B1*)** bitcast ([5 x i8*]* @_ZTV2B1 to void (%struct.B1*)**), i64 2)
+// CHECK-NEXT:  call void [[T3]](%struct.B1* [[T4:%.*]])
+
+
+struct B1 { 
+  virtual ~B1(); 
+};
+
+B1::~B1() {}
+
+void DELETE(B1 *pb1) {
+  pb1->B1::~B1();
+}





More information about the cfe-commits mailing list