r261535 - [MS ABI] Correctly handle dllimport'd explicit instantiation declaration w/ vbases

David Majnemer via cfe-commits cfe-commits at lists.llvm.org
Mon Feb 22 09:22:09 PST 2016


Author: majnemer
Date: Mon Feb 22 11:22:08 2016
New Revision: 261535

URL: http://llvm.org/viewvc/llvm-project?rev=261535&view=rev
Log:
[MS ABI] Correctly handle dllimport'd explicit instantiation declaration w/ vbases

We gave a VBTable dllimport storage class and external linkage while
also providing an initializer.  An initializer is only valid if the
VBTable has available_externally linkage.  Fix this by setting the
linkage to available_externally in situ while generating the
initializer.

This fixes PR26686.

Modified:
    cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
    cfe/trunk/test/CodeGenCXX/PR26569.cpp

Modified: cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp?rev=261535&r1=261534&r2=261535&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp (original)
+++ cfe/trunk/lib/CodeGen/MicrosoftCXXABI.cpp Mon Feb 22 11:22:08 2016
@@ -2039,6 +2039,9 @@ void MicrosoftCXXABI::emitVBTableDefinit
     llvm::ArrayType::get(CGM.IntTy, Offsets.size());
   llvm::Constant *Init = llvm::ConstantArray::get(VBTableType, Offsets);
   GV->setInitializer(Init);
+
+  if (RD->hasAttr<DLLImportAttr>())
+    GV->setLinkage(llvm::GlobalVariable::AvailableExternallyLinkage);
 }
 
 llvm::Value *MicrosoftCXXABI::performThisAdjustment(CodeGenFunction &CGF,

Modified: cfe/trunk/test/CodeGenCXX/PR26569.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/PR26569.cpp?rev=261535&r1=261534&r2=261535&view=diff
==============================================================================
--- cfe/trunk/test/CodeGenCXX/PR26569.cpp (original)
+++ cfe/trunk/test/CodeGenCXX/PR26569.cpp Mon Feb 22 11:22:08 2016
@@ -4,14 +4,17 @@ class A {
   virtual void m_fn1();
 };
 template <typename>
-class B : A {};
+class B : virtual A {};
 
 extern template class __declspec(dllimport) B<int>;
 class __declspec(dllexport) C : B<int> {};
 
-// CHECK: @[[VTABLE_C:.*]] = private unnamed_addr constant [2 x i8*] [i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4C@@6B@" to i8*), i8* bitcast (void (%class.A*)* @"\01?m_fn1 at A@@EAEXXZ" to i8*)]
-// CHECK: @[[VTABLE_B:.*]] = private unnamed_addr constant [2 x i8*] [i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4?$B at H@@6B@" to i8*), i8* bitcast (void (%class.A*)* @"\01?m_fn1 at A@@EAEXXZ" to i8*)], comdat($"\01??_S?$B at H@@6B@")
-// CHECK: @[[VTABLE_A:.*]] = private unnamed_addr constant [2 x i8*] [i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4A@@6B@" to i8*), i8* bitcast (void (%class.A*)* @"\01?m_fn1 at A@@EAEXXZ" to i8*)], comdat($"\01??_7A@@6B@")
-// CHECK: @"\01??_7C@@6B@" = dllexport unnamed_addr alias i8*, getelementptr inbounds ([2 x i8*], [2 x i8*]* @[[VTABLE_C]], i32 0, i32 1)
-// CHECK: @"\01??_S?$B at H@@6B@" = unnamed_addr alias i8*, getelementptr inbounds ([2 x i8*], [2 x i8*]* @[[VTABLE_B]], i32 0, i32 1)
-// CHECK: @"\01??_7A@@6B@" = unnamed_addr alias i8*, getelementptr inbounds ([2 x i8*], [2 x i8*]* @[[VTABLE_A]], i32 0, i32 1)
+// CHECK-DAG: @[[VTABLE_C:.*]] = private unnamed_addr constant [2 x i8*] [i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4C@@6B@" to i8*), i8* bitcast (void (%class.A*)* @"\01?m_fn1 at A@@EAEXXZ" to i8*)]
+// CHECK-DAG: @[[VTABLE_B:.*]] = private unnamed_addr constant [2 x i8*] [i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4?$B at H@@6B@" to i8*), i8* bitcast (void (%class.A*)* @"\01?m_fn1 at A@@EAEXXZ" to i8*)], comdat($"\01??_S?$B at H@@6B@")
+// CHECK-DAG: @[[VTABLE_A:.*]] = private unnamed_addr constant [2 x i8*] [i8* bitcast (%rtti.CompleteObjectLocator* @"\01??_R4A@@6B@" to i8*), i8* bitcast (void (%class.A*)* @"\01?m_fn1 at A@@EAEXXZ" to i8*)], comdat($"\01??_7A@@6B@")
+
+// CHECK-DAG: @"\01??_7C@@6B@" = dllexport unnamed_addr alias i8*, getelementptr inbounds ([2 x i8*], [2 x i8*]* @[[VTABLE_C]], i32 0, i32 1)
+// CHECK-DAG: @"\01??_S?$B at H@@6B@" = unnamed_addr alias i8*, getelementptr inbounds ([2 x i8*], [2 x i8*]* @[[VTABLE_B]], i32 0, i32 1)
+// CHECK-DAG: @"\01??_7A@@6B@" = unnamed_addr alias i8*, getelementptr inbounds ([2 x i8*], [2 x i8*]* @[[VTABLE_A]], i32 0, i32 1)
+
+// CHECK-DAG: @"\01??_8?$B at H@@7B@" = available_externally dllimport unnamed_addr constant [2 x i32] [i32 0, i32 4]




More information about the cfe-commits mailing list