Skip to content

[clang codegen][regression] Add dso_local/hidden/etc. markings to VTT definitions and declarations #72452

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions clang/lib/CodeGen/CGVTT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ CodeGenVTables::EmitVTTDefinition(llvm::GlobalVariable *VTT,

if (CGM.supportsCOMDAT() && VTT->isWeakForLinker())
VTT->setComdat(CGM.getModule().getOrInsertComdat(VTT->getName()));

// Set the visibility. This will already have been set on the VTT declaration.
// Set it again, now that we have a definition, as the implicit visibility can
// apply differently to definitions.
CGM.setGVProperties(VTT, RD);
}

llvm::GlobalVariable *CodeGenVTables::GetAddrOfVTT(const CXXRecordDecl *RD) {
Expand Down
9 changes: 9 additions & 0 deletions clang/test/CodeGenCXX/visibility.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,9 @@ namespace test27 {
// CHECK: @_ZGVZN6test681fC1EvE4test = linkonce_odr global
// CHECK-HIDDEN: @_ZGVZN6test681fC1EvE4test = linkonce_odr hidden global

// CHECK-HIDDEN: @_ZTVN6test701DE = linkonce_odr hidden unnamed_addr constant { [3 x ptr] } { [3 x ptr] [ptr null, ptr null, ptr @_ZTIN6test701DE] }, align 8
// CHECK-HIDDEN: @_ZTTN6test701DE = linkonce_odr hidden unnamed_addr constant [1 x ptr] [ptr getelementptr inbounds ({ [3 x ptr] }, ptr @_ZTVN6test701DE, i32 0, inrange i32 0, i32 3)], align 8

// CHECK: @_ZZN6Test193fooIiEEvvE1a = linkonce_odr global
// CHECK-HIDDEN: @_ZZN6Test193fooIiEEvvE1a = linkonce_odr hidden global

Expand Down Expand Up @@ -1422,6 +1425,12 @@ namespace test70 {
~B();
};
B::~B() {}

// Make sure both the vtable and VTT declarations are marked "hidden"
// when "-fvisibilty=hidden" is in use.
class C {};
class D : virtual C {};
D d;
// Check lines at top of file.
}

Expand Down