diff options
author | Anton Korobeynikov <asl@math.spbu.ru> | 2008-09-09 20:05:04 +0000 |
---|---|---|
committer | Anton Korobeynikov <asl@math.spbu.ru> | 2008-09-09 20:05:04 +0000 |
commit | 1a1140429ee5ca58d9a25aea570940826e478125 (patch) | |
tree | abc276017e04ec02cf4b83ba2f6f5305b0f34c3f /llvm/lib | |
parent | fac18fe2ee18df098626007137350dfa00c16bab (diff) | |
download | bcm5719-llvm-1a1140429ee5ca58d9a25aea570940826e478125.tar.gz bcm5719-llvm-1a1140429ee5ca58d9a25aea570940826e478125.zip |
Make safer variant of alias resolution routine to be default
llvm-svn: 56005
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Linker/LinkModules.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Transforms/IPO/GlobalOpt.cpp | 3 | ||||
-rw-r--r-- | llvm/lib/VMCore/Globals.cpp | 6 | ||||
-rw-r--r-- | llvm/lib/VMCore/Verifier.cpp | 2 |
7 files changed, 9 insertions, 10 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 747c1400fcc..31cd2e3393e 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -949,7 +949,7 @@ SDValue SelectionDAG::getGlobalAddress(const GlobalValue *GV, if (!GVar) { // If GV is an alias then use the aliasee for determining thread-localness. if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(GV)) - GVar = dyn_cast_or_null<GlobalVariable>(GA->resolveAliasedGlobal()); + GVar = dyn_cast_or_null<GlobalVariable>(GA->resolveAliasedGlobal(false)); } if (GVar && GVar->isThreadLocal()) diff --git a/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp b/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp index da4cd095fad..02752a01cdd 100644 --- a/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp +++ b/llvm/lib/ExecutionEngine/JIT/JITEmitter.cpp @@ -567,7 +567,7 @@ void *JITEmitter::getPointerToGlobal(GlobalValue *V, void *Reference, return TheJIT->getOrEmitGlobalVariable(GV); } if (GlobalAlias *GA = dyn_cast<GlobalAlias>(V)) - return TheJIT->getPointerToGlobal(GA->resolveAliasedGlobal()); + return TheJIT->getPointerToGlobal(GA->resolveAliasedGlobal(false)); // If we have already compiled the function, return a pointer to its body. Function *F = cast<Function>(V); diff --git a/llvm/lib/Linker/LinkModules.cpp b/llvm/lib/Linker/LinkModules.cpp index f4ebe6b10c0..b867705fe12 100644 --- a/llvm/lib/Linker/LinkModules.cpp +++ b/llvm/lib/Linker/LinkModules.cpp @@ -1169,7 +1169,7 @@ static bool LinkAppendingVars(Module *M, static bool ResolveAliases(Module *Dest) { for (Module::alias_iterator I = Dest->alias_begin(), E = Dest->alias_end(); I != E; ++I) - if (const GlobalValue *GV = I->resolveAliasedGlobal(/*traverseWeak*/ false)) + if (const GlobalValue *GV = I->resolveAliasedGlobal()) if (GV != I && !GV->isDeclaration()) I->replaceAllUsesWith(const_cast<GlobalValue*>(GV)); diff --git a/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp b/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp index eb31752ded9..6977ead58e1 100644 --- a/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp +++ b/llvm/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp @@ -369,7 +369,7 @@ void X86ATTAsmPrinter::printOperand(const MachineInstr *MI, unsigned OpNo, // If GV is an alias then use the aliasee for determining // thread-localness. if (const GlobalAlias *GA = dyn_cast<GlobalAlias>(GV)) - GVar = dyn_cast_or_null<GlobalVariable>(GA->resolveAliasedGlobal()); + GVar = dyn_cast_or_null<GlobalVariable>(GA->resolveAliasedGlobal(false)); } bool isThreadLocal = GVar && GVar->isThreadLocal(); diff --git a/llvm/lib/Transforms/IPO/GlobalOpt.cpp b/llvm/lib/Transforms/IPO/GlobalOpt.cpp index 8c6631aa2bc..0c059ff0146 100644 --- a/llvm/lib/Transforms/IPO/GlobalOpt.cpp +++ b/llvm/lib/Transforms/IPO/GlobalOpt.cpp @@ -2223,7 +2223,7 @@ bool GlobalOpt::ResolveAliases(Module &M) { if (I->use_empty()) continue; - if (const GlobalValue *GV = I->resolveAliasedGlobal(/*traverseWeak*/ false)) + if (const GlobalValue *GV = I->resolveAliasedGlobal()) if (GV != I) { I->replaceAllUsesWith(const_cast<GlobalValue*>(GV)); Changed = true; @@ -2252,7 +2252,6 @@ bool GlobalOpt::runOnModule(Module &M) { // Optimize non-address-taken globals. LocalChange |= OptimizeGlobalVars(M); - Changed |= LocalChange; // Resolve aliases, when possible. LocalChange |= ResolveAliases(M); diff --git a/llvm/lib/VMCore/Globals.cpp b/llvm/lib/VMCore/Globals.cpp index 7ceda6cd53d..c917dfc3be7 100644 --- a/llvm/lib/VMCore/Globals.cpp +++ b/llvm/lib/VMCore/Globals.cpp @@ -248,11 +248,11 @@ const GlobalValue *GlobalAlias::getAliasedGlobal() const { return 0; } -const GlobalValue *GlobalAlias::resolveAliasedGlobal(bool traverseWeak) const { +const GlobalValue *GlobalAlias::resolveAliasedGlobal(bool stopOnWeak) const { SmallPtrSet<const GlobalValue*, 3> Visited; // Check if we need to stop early. - if (!traverseWeak && hasWeakLinkage()) + if (stopOnWeak && hasWeakLinkage()) return this; const GlobalValue *GV = getAliasedGlobal(); @@ -260,7 +260,7 @@ const GlobalValue *GlobalAlias::resolveAliasedGlobal(bool traverseWeak) const { // Iterate over aliasing chain, stopping on weak alias if necessary. while (const GlobalAlias *GA = dyn_cast<GlobalAlias>(GV)) { - if (!traverseWeak && GA->hasWeakLinkage()) + if (stopOnWeak && GA->hasWeakLinkage()) break; GV = GA->getAliasedGlobal(); diff --git a/llvm/lib/VMCore/Verifier.cpp b/llvm/lib/VMCore/Verifier.cpp index af11fce5e72..be053aba944 100644 --- a/llvm/lib/VMCore/Verifier.cpp +++ b/llvm/lib/VMCore/Verifier.cpp @@ -394,7 +394,7 @@ void Verifier::visitGlobalAlias(GlobalAlias &GA) { &GA); } - const GlobalValue* Aliasee = GA.resolveAliasedGlobal(); + const GlobalValue* Aliasee = GA.resolveAliasedGlobal(/*stopOnWeak*/ false); Assert1(Aliasee, "Aliasing chain should end with function or global variable", &GA); |