diff options
author | Peter Collingbourne <peter@pcc.me.uk> | 2015-03-14 00:00:49 +0000 |
---|---|---|
committer | Peter Collingbourne <peter@pcc.me.uk> | 2015-03-14 00:00:49 +0000 |
commit | c9f277f754f3f2a805a077c7b53ef8216e598ec9 (patch) | |
tree | e156dc946ba320c3b4fb344b2e6b528d8272e2ad /llvm/lib/Transforms/IPO/LowerBitSets.cpp | |
parent | 5c9c706ab27e36ef77dee13a571cc949edec2ee6 (diff) | |
download | bcm5719-llvm-c9f277f754f3f2a805a077c7b53ef8216e598ec9.tar.gz bcm5719-llvm-c9f277f754f3f2a805a077c7b53ef8216e598ec9.zip |
LowerBitSets: Do not export symbols for bit set referenced globals on Darwin.
The linker on that platform may re-order symbols or strip dead symbols, which
will break bit set checks. Avoid this by hiding the symbols from the linker.
llvm-svn: 232235
Diffstat (limited to 'llvm/lib/Transforms/IPO/LowerBitSets.cpp')
-rw-r--r-- | llvm/lib/Transforms/IPO/LowerBitSets.cpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/IPO/LowerBitSets.cpp b/llvm/lib/Transforms/IPO/LowerBitSets.cpp index 9eb5cdba0e5..8602642103c 100644 --- a/llvm/lib/Transforms/IPO/LowerBitSets.cpp +++ b/llvm/lib/Transforms/IPO/LowerBitSets.cpp @@ -16,6 +16,7 @@ #include "llvm/Transforms/IPO.h" #include "llvm/ADT/EquivalenceClasses.h" #include "llvm/ADT/Statistic.h" +#include "llvm/ADT/Triple.h" #include "llvm/IR/Constant.h" #include "llvm/IR/Constants.h" #include "llvm/IR/GlobalVariable.h" @@ -186,6 +187,7 @@ struct LowerBitSets : public ModulePass { Module *M; + bool LinkerSubsectionsViaSymbols; IntegerType *Int1Ty; IntegerType *Int8Ty; IntegerType *Int32Ty; @@ -235,6 +237,9 @@ bool LowerBitSets::doInitialization(Module &Mod) { M = &Mod; const DataLayout &DL = Mod.getDataLayout(); + Triple TargetTriple(M->getTargetTriple()); + LinkerSubsectionsViaSymbols = TargetTriple.isMacOSX(); + Int1Ty = Type::getInt1Ty(M->getContext()); Int8Ty = Type::getInt8Ty(M->getContext()); Int32Ty = Type::getInt32Ty(M->getContext()); @@ -524,9 +529,12 @@ void LowerBitSets::buildBitSetsFromGlobals( ConstantInt::get(Int32Ty, I * 2)}; Constant *CombinedGlobalElemPtr = ConstantExpr::getGetElementPtr(CombinedGlobal, CombinedGlobalIdxs); + GlobalValue::LinkageTypes GAliasLinkage = LinkerSubsectionsViaSymbols + ? GlobalValue::PrivateLinkage + : Globals[I]->getLinkage(); GlobalAlias *GAlias = GlobalAlias::create( Globals[I]->getType()->getElementType(), - Globals[I]->getType()->getAddressSpace(), Globals[I]->getLinkage(), + Globals[I]->getType()->getAddressSpace(), GAliasLinkage, "", CombinedGlobalElemPtr, M); GAlias->takeName(Globals[I]); Globals[I]->replaceAllUsesWith(GAlias); |