diff options
author | Ben Dunbobbin <Ben.Dunbobbin@sony.com> | 2020-11-23 09:27:38 +0000 |
---|---|---|
committer | Ben Dunbobbin <Ben.Dunbobbin@sony.com> | 2020-11-24 00:32:14 +0000 |
commit | e42021d5cc25a8dc7e3efac1e7007cc0c1a7b2bd (patch) | |
tree | cab3d688fc563dc623ebc3d19cf8d5206005da8e /clang/lib/CodeGen/CodeGenModule.cpp | |
parent | 1b63177a56e8cd6196778d2b90295f03e96b5800 (diff) | |
download | llvm-e42021d5cc25a8dc7e3efac1e7007cc0c1a7b2bd.zip llvm-e42021d5cc25a8dc7e3efac1e7007cc0c1a7b2bd.tar.gz llvm-e42021d5cc25a8dc7e3efac1e7007cc0c1a7b2bd.tar.bz2 |
[Clang][-fvisibility-from-dllstorageclass] Set DSO Locality from final visibility
Ensure that the DSO Locality of the globals in the IR is derived from
their final visibility when using -fvisibility-from-dllstorageclass.
To accomplish this we reset the DSO locality of globals (before
setting their visibility from their dllstorageclass) at the end of
IRGen in Clang. This removes any effects that visibility options or
annotations may have had on the DSO locality.
The resulting DSO locality of the globals will be pessimistic
w.r.t. to the normal compiler IRGen.
Differential Revision: https://reviews.llvm.org/D91779
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
-rw-r--r-- | clang/lib/CodeGen/CodeGenModule.cpp | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/clang/lib/CodeGen/CodeGenModule.cpp b/clang/lib/CodeGen/CodeGenModule.cpp index f56b737..6d0228e 100644 --- a/clang/lib/CodeGen/CodeGenModule.cpp +++ b/clang/lib/CodeGen/CodeGenModule.cpp @@ -420,6 +420,13 @@ static void setVisibilityFromDLLStorageClass(const clang::LangOptions &LO, if (GV.hasAppendingLinkage() || GV.hasLocalLinkage()) continue; + // Reset DSO locality before setting the visibility. This removes + // any effects that visibility options and annotations may have + // had on the DSO locality. Setting the visibility will implicitly set + // appropriate globals to DSO Local; however, this will be pessimistic + // w.r.t. to the normal compiler IRGen. + GV.setDSOLocal(false); + if (GV.isDeclarationForLinker()) { GV.setVisibility(GV.getDLLStorageClass() == llvm::GlobalValue::DLLImportStorageClass |