diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2018-01-11 22:15:05 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2018-01-11 22:15:05 +0000 |
commit | e4b0231c63d40408d06ff4c3669ded4b4ecaaa85 (patch) | |
tree | 9e89f032c39da53ab74bd3d38a87264e2b5ceaa4 /llvm/lib/AsmParser | |
parent | e97654b2f28072ad9123006c05e03efd82852982 (diff) | |
download | bcm5719-llvm-e4b0231c63d40408d06ff4c3669ded4b4ecaaa85.tar.gz bcm5719-llvm-e4b0231c63d40408d06ff4c3669ded4b4ecaaa85.zip |
Make internal/private GVs implicitly dso_local.
While updating clang tests for having clang set dso_local I noticed
that:
- There are *a lot* of tests to update.
- Many of the updates are redundant.
They are redundant because a GV is "obviously dso_local". This patch
starts formalizing that a bit by requiring that internal and private
GVs be dso_local too. Since they all are, we don't have to print
dso_local to the textual representation, making it a bit more compact
and easier to read.
llvm-svn: 322317
Diffstat (limited to 'llvm/lib/AsmParser')
-rw-r--r-- | llvm/lib/AsmParser/LLParser.cpp | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/llvm/lib/AsmParser/LLParser.cpp b/llvm/lib/AsmParser/LLParser.cpp index c3ab95550e0..6f425721c1b 100644 --- a/llvm/lib/AsmParser/LLParser.cpp +++ b/llvm/lib/AsmParser/LLParser.cpp @@ -715,6 +715,13 @@ static bool isValidVisibilityForLinkage(unsigned V, unsigned L) { (GlobalValue::VisibilityTypes)V == GlobalValue::DefaultVisibility; } +// If there was an explicit dso_local, update GV. In the absence of an explicit +// dso_local we keep the default value. +static void maybeSetDSOLocal(bool DSOLocal, GlobalValue &GV) { + if (DSOLocal) + GV.setDSOLocal(true); +} + /// parseIndirectSymbol: /// ::= GlobalVar '=' OptionalLinkage OptionalPreemptionSpecifier /// OptionalVisibility OptionalDLLStorageClass @@ -826,7 +833,7 @@ bool LLParser::parseIndirectSymbol(const std::string &Name, LocTy NameLoc, GA->setVisibility((GlobalValue::VisibilityTypes)Visibility); GA->setDLLStorageClass((GlobalValue::DLLStorageClassTypes)DLLStorageClass); GA->setUnnamedAddr(UnnamedAddr); - GA->setDSOLocal(DSOLocal); + maybeSetDSOLocal(DSOLocal, *GA); if (Name.empty()) NumberedVals.push_back(GA.get()); @@ -947,7 +954,7 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc, GV->setInitializer(Init); GV->setConstant(IsConstant); GV->setLinkage((GlobalValue::LinkageTypes)Linkage); - GV->setDSOLocal(DSOLocal); + maybeSetDSOLocal(DSOLocal, *GV); GV->setVisibility((GlobalValue::VisibilityTypes)Visibility); GV->setDLLStorageClass((GlobalValue::DLLStorageClassTypes)DLLStorageClass); GV->setExternallyInitialized(IsExternallyInitialized); @@ -4923,7 +4930,7 @@ bool LLParser::ParseFunctionHeader(Function *&Fn, bool isDefine) { NumberedVals.push_back(Fn); Fn->setLinkage((GlobalValue::LinkageTypes)Linkage); - Fn->setDSOLocal(DSOLocal); + maybeSetDSOLocal(DSOLocal, *Fn); Fn->setVisibility((GlobalValue::VisibilityTypes)Visibility); Fn->setDLLStorageClass((GlobalValue::DLLStorageClassTypes)DLLStorageClass); Fn->setCallingConv(CC); |