summaryrefslogtreecommitdiffstats
path: root/clang/lib/CodeGen/CGVTables.cpp
diff options
context:
space:
mode:
authorPetr Hosek <phosek@chromium.org>2019-02-11 20:13:42 +0000
committerPetr Hosek <phosek@chromium.org>2019-02-11 20:13:42 +0000
commit7c8952197b86790b31731d34d559281840916e1f (patch)
treeb4f08c91a66608be3fa1cc7199dbac1f6d6ce3fa /clang/lib/CodeGen/CGVTables.cpp
parentb31180d0de2d32851b54ab0f00718eea366b1af2 (diff)
downloadbcm5719-llvm-7c8952197b86790b31731d34d559281840916e1f.tar.gz
bcm5719-llvm-7c8952197b86790b31731d34d559281840916e1f.zip
[CodeGen] Set construction vtable visibility after creating initializer
We must only set the construction vtable visibility after we create the vtable initializer, otherwise the global value will be treated as declaration rather than definition and the visibility won't be set. Differential Revision: https://reviews.llvm.org/D58010 llvm-svn: 353742
Diffstat (limited to 'clang/lib/CodeGen/CGVTables.cpp')
-rw-r--r--clang/lib/CodeGen/CGVTables.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/clang/lib/CodeGen/CGVTables.cpp b/clang/lib/CodeGen/CGVTables.cpp
index a7b81a01f7f..3cb3d354483 100644
--- a/clang/lib/CodeGen/CGVTables.cpp
+++ b/clang/lib/CodeGen/CGVTables.cpp
@@ -761,7 +761,6 @@ CodeGenVTables::GenerateConstructionVTable(const CXXRecordDecl *RD,
// Create the variable that will hold the construction vtable.
llvm::GlobalVariable *VTable =
CGM.CreateOrReplaceCXXRuntimeVariable(Name, VTType, Linkage, Align);
- CGM.setGVProperties(VTable, RD);
// V-tables are always unnamed_addr.
VTable->setUnnamedAddr(llvm::GlobalValue::UnnamedAddr::Global);
@@ -775,6 +774,11 @@ CodeGenVTables::GenerateConstructionVTable(const CXXRecordDecl *RD,
createVTableInitializer(components, *VTLayout, RTTI);
components.finishAndSetAsInitializer(VTable);
+ // Set properties only after the initializer has been set to ensure that the
+ // GV is treated as definition and not declaration.
+ assert(!VTable->isDeclaration() && "Shouldn't set properties on declaration");
+ CGM.setGVProperties(VTable, RD);
+
CGM.EmitVTableTypeMetadata(VTable, *VTLayout.get());
return VTable;
OpenPOWER on IntegriCloud