Skip to content

Commit 4f8c191

Browse files
committed
[CodeGen] Don't set the visibility of a ptrauth virtual member function
pointer thunk to hidden if the thunk has internal linkage rdar://76372295
1 parent b63524b commit 4f8c191

File tree

2 files changed

+16
-1
lines changed

2 files changed

+16
-1
lines changed

clang/lib/CodeGen/ItaniumCXXABI.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3148,7 +3148,8 @@ ItaniumCXXABI::getOrCreateVirtualFunctionPointerThunk(const CXXMethodDecl *MD) {
31483148
: llvm::GlobalValue::InternalLinkage;
31493149
ThunkFn =
31503150
llvm::Function::Create(ThunkTy, Linkage, ThunkName, &CGM.getModule());
3151-
ThunkFn->setVisibility(llvm::GlobalValue::HiddenVisibility);
3151+
if (Linkage == llvm::GlobalValue::LinkOnceODRLinkage)
3152+
ThunkFn->setVisibility(llvm::GlobalValue::HiddenVisibility);
31523153
assert(ThunkFn->getName() == ThunkName && "name was uniqued!");
31533154

31543155
CGM.SetLLVMFunctionAttributes(MD, FnInfo, ThunkFn);

clang/test/CodeGenCXX/ptrauth-member-function-pointer.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,20 @@ namespace testNonVirtualThunk {
371371
D d;
372372
}
373373

374+
// CHECK: define internal void @_ZN22TestAnonymousNamespace12_GLOBAL__N_11S3fooEv_vfpthunk_(
375+
376+
namespace TestAnonymousNamespace {
377+
namespace {
378+
struct S {
379+
virtual void foo(){};
380+
};
381+
} // namespace
382+
383+
void test() {
384+
auto t = &S::foo;
385+
}
386+
} // namespace TestAnonymousNamespace
387+
374388
// CHECK: define void @_Z39test_builtin_ptrauth_type_discriminatorv()
375389
// CHECK: store i32 [[TYPEDISC0]], i32* %
376390
// CHECK: store i32 [[TYPEDISC1]], i32* %

0 commit comments

Comments
 (0)