r260062 - [MS ABI] Don't emit RTTI descriptors for dllimport vtables

David Majnemer via cfe-commits cfe-commits at lists.llvm.org
Sun Feb 7 14:42:05 PST 2016


Author: majnemer
Date: Sun Feb  7 16:42:05 2016
New Revision: 260062

URL: http://llvm.org/viewvc/llvm-project?rev=260062&view=rev
Log:
[MS ABI] Don't emit RTTI descriptors for dllimport vtables

A dllimport'd vtable always points one past the RTTI data, this means
that the initializer will never end up referencing the data.  Our
emission is a harmless waste.

Modified:
    cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
    cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp

Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=260062&r1=260061&r2=260062&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Sun Feb  7 16:42:05 2016
@@ -1567,7 +1567,9 @@ void MicrosoftCXXABI::emitVTableDefiniti
     if (VTable->hasInitializer())
       continue;
 
-    llvm::Constant *RTTI = getContext().getLangOpts().RTTIData
+    llvm::Constant *RTTI = getContext().getLangOpts().RTTIData &&
+                                   VTable->getDLLStorageClass() !=
+                                       llvm::GlobalValue::DLLImportStorageClass
                                ? getMSCompleteObjectLocator(RD, Info)
                                : nullptr;
 

Modified: cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp?rev=260062&r1=260061&r2=260062&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/microsoft-abi-vftables.cpp Sun Feb  7 16:42:05 2016
@@ -4,6 +4,8 @@
 // RTTI-DAG: $"\01??_7S@@6B@" = comdat largest
 // RTTI-DAG: $"\01??_7V@@6B@" = comdat largest
 
+// RTTI-NOT: @"\01??_R4U@@6B@"
+
 struct S {
   virtual ~S();
 } s;




More information about the cfe-commits mailing list