diff options
| author | Rafael Espindola <rafael.espindola@gmail.com> | 2018-01-18 02:08:23 +0000 |
|---|---|---|
| committer | Rafael Espindola <rafael.espindola@gmail.com> | 2018-01-18 02:08:23 +0000 |
| commit | 9fbc040599588149d34048a81b73b9422a25f6a4 (patch) | |
| tree | 81b22f7b9eec3f941ea6f5c37f3f36d4c29d6f6f /llvm/lib/IR | |
| parent | a9346e050f301dfea9e1cf50d39a4b7180091b44 (diff) | |
| download | bcm5719-llvm-9fbc040599588149d34048a81b73b9422a25f6a4.tar.gz bcm5719-llvm-9fbc040599588149d34048a81b73b9422a25f6a4.zip | |
Make GlobalValues with non-default visibilility dso_local.
This is similar to r322317, but for visibility. It is not as neat
because we have to special case extern_weak.
The idea is the same as the previous change, make the transition to
explicit dso_local easier for the frontends. With this they only have
to add dso_local to symbols where we need some external information to
decide if it is dso_local (like it being part of an ELF executable).
llvm-svn: 322806
Diffstat (limited to 'llvm/lib/IR')
| -rw-r--r-- | llvm/lib/IR/AsmWriter.cpp | 7 | ||||
| -rw-r--r-- | llvm/lib/IR/Verifier.cpp | 4 |
2 files changed, 9 insertions, 2 deletions
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp index 27a75927832..7c647605894 100644 --- a/llvm/lib/IR/AsmWriter.cpp +++ b/llvm/lib/IR/AsmWriter.cpp @@ -2499,8 +2499,11 @@ static void PrintVisibility(GlobalValue::VisibilityTypes Vis, static void PrintDSOLocation(const GlobalValue &GV, formatted_raw_ostream &Out) { - // GVs with local linkage are implicitly dso_local, so we don't print it. - if (GV.isDSOLocal() && !GV.hasLocalLinkage()) + // GVs with local linkage or non default visibility are implicitly dso_local, + // so we don't print it. + bool Implicit = GV.hasLocalLinkage() || + (!GV.hasExternalWeakLinkage() && !GV.hasDefaultVisibility()); + if (GV.isDSOLocal() && !Implicit) Out << "dso_local "; } diff --git a/llvm/lib/IR/Verifier.cpp b/llvm/lib/IR/Verifier.cpp index 42fec7e3d98..f7775be6961 100644 --- a/llvm/lib/IR/Verifier.cpp +++ b/llvm/lib/IR/Verifier.cpp @@ -575,6 +575,10 @@ void Verifier::visitGlobalValue(const GlobalValue &GV) { "GlobalValue with private or internal linkage must be dso_local!", &GV); + if (!GV.hasDefaultVisibility() && !GV.hasExternalWeakLinkage()) + Assert(GV.isDSOLocal(), + "GlobalValue with non default visibility must be dso_local!", &GV); + forEachUser(&GV, GlobalValueVisited, [&](const Value *V) -> bool { if (const Instruction *I = dyn_cast<Instruction>(V)) { if (!I->getParent() || !I->getParent()->getParent()) |

