]> granicus.if.org Git - clang/commitdiff
Itanium ABI: Update getAddrOfVTable to set the DLL storage class for vtables
authorHans Wennborg <hans@hanshq.net>
Mon, 2 Jun 2014 23:13:03 +0000 (23:13 +0000)
committerHans Wennborg <hans@hanshq.net>
Mon, 2 Jun 2014 23:13:03 +0000 (23:13 +0000)
This corresponds to the same change for the MS ABI in r209908.

Differential Revision: http://reviews.llvm.org/D3993

git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@210054 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/ItaniumCXXABI.cpp
test/CodeGenCXX/dllexport.cpp
test/CodeGenCXX/dllimport.cpp

index f5d23726a9c7a4c14f925ded9de08e0d55ea81a8..951174b4858e71db4b66976219c8eabc32cab35e 100644 (file)
@@ -1069,6 +1069,12 @@ llvm::GlobalVariable *ItaniumCXXABI::getAddrOfVTable(const CXXRecordDecl *RD,
   VTable = CGM.CreateOrReplaceCXXRuntimeVariable(
       Name, ArrayType, llvm::GlobalValue::ExternalLinkage);
   VTable->setUnnamedAddr(true);
+
+  if (RD->hasAttr<DLLImportAttr>())
+    VTable->setDLLStorageClass(llvm::GlobalValue::DLLImportStorageClass);
+  else if (RD->hasAttr<DLLExportAttr>())
+    VTable->setDLLStorageClass(llvm::GlobalValue::DLLExportStorageClass);
+
   return VTable;
 }
 
index df8524d03f01efaf54bbc60a430a32cbb1bf25c4..adb856c89d854c88bc4494fab00602a49044307b 100644 (file)
@@ -502,6 +502,7 @@ struct __declspec(dllexport) W { virtual void foo() {} };
 // M32-DAG: define weak_odr dllexport x86_thiscallcc %struct.W* @"\01??0W@@QAE@ABU0@@Z"
 // vftable:
 // M32-DAG: @"\01??_7W@@6B@" = weak_odr dllexport unnamed_addr constant [1 x i8*] [i8* bitcast (void (%struct.W*)* @"\01?foo@W@@UAEXXZ" to i8*)]
+// G32-DAG: @_ZTV1W = weak_odr dllexport unnamed_addr constant [3 x i8*] [i8* null, i8* bitcast ({ i8*, i8* }* @_ZTI1W to i8*), i8* bitcast (void (%struct.W*)* @_ZN1W3fooEv to i8*)]
 
 struct __declspec(dllexport) X : public virtual W {};
 // vbtable:
index a0d153e408da1d6fcb4330f3df3eef4c06940ffb..ed36d8d04402ec2862789adf4e3d9ee1b5a7388f 100644 (file)
@@ -219,11 +219,6 @@ USE(inlineDef)
 __declspec(dllimport) __attribute__((noinline)) inline void noinline() {}
 USE(noinline)
 
-// MSC-NOT: @"\01?alwaysInline@@YAXXZ"()
-// GNU-NOT: @_Z12alwaysInlinev()
-__declspec(dllimport) __attribute__((always_inline)) inline void alwaysInline() {}
-USE(alwaysInline)
-
 // Redeclarations
 // MSC-DAG: declare dllimport void @"\01?redecl1@@YAXXZ"()
 // GNU-DAG: declare dllimport void @_Z7redecl1v()
@@ -527,6 +522,14 @@ struct __declspec(dllimport) W { virtual void foo() {} };
 USECLASS(W)
 // vftable:
 // MO1-DAG: @"\01??_7W@@6B@" = available_externally dllimport unnamed_addr constant [1 x i8*] [i8* bitcast (void (%struct.W*)* @"\01?foo@W@@UAEXXZ" to i8*)]
+// GO1-DAG: @_ZTV1W = available_externally dllimport unnamed_addr constant [3 x i8*] [i8* null, i8* null, i8* bitcast (void (%struct.W*)* @_ZN1W3fooEv to i8*)]
+
+struct __declspec(dllimport) KeyFuncClass {
+  constexpr KeyFuncClass() {}
+  virtual void foo();
+};
+constexpr KeyFuncClass keyFuncClassVar;
+// G32-DAG: @_ZTV12KeyFuncClass = external dllimport unnamed_addr constant [3 x i8*]
 
 struct __declspec(dllimport) X : public virtual W {};
 USECLASS(X)
@@ -567,3 +570,14 @@ namespace Vtordisp {
   };
   template class C<char>;
 }
+
+//===----------------------------------------------------------------------===//
+// Negative checks
+//===----------------------------------------------------------------------===//
+
+// These checks are at the end to avoid interference with the DAG checks.
+
+// MSC-NOT: @"\01?alwaysInline@@YAXXZ"()
+// GNU-NOT: @_Z12alwaysInlinev()
+__declspec(dllimport) __attribute__((always_inline)) inline void alwaysInline() {}
+USE(alwaysInline)