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
diff --git a/llvm/lib/IR/AsmWriter.cpp b/llvm/lib/IR/AsmWriter.cpp
index 27a7592..7c64760 100644
--- a/llvm/lib/IR/AsmWriter.cpp
+++ b/llvm/lib/IR/AsmWriter.cpp
@@ -2499,8 +2499,11 @@
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 ";
}