[llvm-commits] [llvm] r56005 - in /llvm/trunk: include/llvm/GlobalAlias.h lib/CodeGen/SelectionDAG/SelectionDAG.cpp lib/ExecutionEngine/JIT/JITEmitter.cpp lib/Linker/LinkModules.cpp lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp lib/Transforms/IPO/GlobalOpt.cpp lib/VMCore/Globals.cpp lib/VMCore/Verifier.cpp
Anton Korobeynikov
asl at math.spbu.ru
Tue Sep 9 13:05:04 PDT 2008
Author: asl
Date: Tue Sep 9 15:05:04 2008
New Revision: 56005
URL: http://llvm.org/viewvc/llvm-project?rev=56005&view=rev
Log:
Make safer variant of alias resolution routine to be default
Modified:
llvm/trunk/include/llvm/GlobalAlias.h
llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp
llvm/trunk/lib/Linker/LinkModules.cpp
llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
llvm/trunk/lib/VMCore/Globals.cpp
llvm/trunk/lib/VMCore/Verifier.cpp
Modified: llvm/trunk/include/llvm/GlobalAlias.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/GlobalAlias.h?rev=56005&r1=56004&r2=56005&view=diff
==============================================================================
--- llvm/trunk/include/llvm/GlobalAlias.h (original)
+++ llvm/trunk/include/llvm/GlobalAlias.h Tue Sep 9 15:05:04 2008
@@ -76,10 +76,10 @@
/// resolveAliasedGlobal() - This method tries to ultimately resolve the alias
/// by going through the aliasing chain and trying to find the very last
- /// global. Returns NULL if a cycle was found. If traverseWeak is true, then
+ /// global. Returns NULL if a cycle was found. If stopOnWeak is false, then
/// the whole chain aliasing chain is traversed, otherwise - only strong
/// aliases.
- const GlobalValue* resolveAliasedGlobal(bool traverseWeak = true) const;
+ const GlobalValue* resolveAliasedGlobal(bool stopOnWeak = true) const;
// Methods for support type inquiry through isa, cast, and dyn_cast:
static inline bool classof(const GlobalAlias *) { return true; }
Modified: llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp?rev=56005&r1=56004&r2=56005&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/SelectionDAG.cpp Tue Sep 9 15:05:04 2008
@@ -949,7 +949,7 @@
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())
Modified: llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp?rev=56005&r1=56004&r2=56005&view=diff
==============================================================================
--- llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp (original)
+++ llvm/trunk/lib/ExecutionEngine/JIT/JITEmitter.cpp Tue Sep 9 15:05:04 2008
@@ -567,7 +567,7 @@
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);
Modified: llvm/trunk/lib/Linker/LinkModules.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Linker/LinkModules.cpp?rev=56005&r1=56004&r2=56005&view=diff
==============================================================================
--- llvm/trunk/lib/Linker/LinkModules.cpp (original)
+++ llvm/trunk/lib/Linker/LinkModules.cpp Tue Sep 9 15:05:04 2008
@@ -1169,7 +1169,7 @@
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));
Modified: llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp?rev=56005&r1=56004&r2=56005&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp (original)
+++ llvm/trunk/lib/Target/X86/AsmPrinter/X86ATTAsmPrinter.cpp Tue Sep 9 15:05:04 2008
@@ -369,7 +369,7 @@
// 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();
Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=56005&r1=56004&r2=56005&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Tue Sep 9 15:05:04 2008
@@ -2223,7 +2223,7 @@
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 @@
// Optimize non-address-taken globals.
LocalChange |= OptimizeGlobalVars(M);
- Changed |= LocalChange;
// Resolve aliases, when possible.
LocalChange |= ResolveAliases(M);
Modified: llvm/trunk/lib/VMCore/Globals.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Globals.cpp?rev=56005&r1=56004&r2=56005&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Globals.cpp (original)
+++ llvm/trunk/lib/VMCore/Globals.cpp Tue Sep 9 15:05:04 2008
@@ -248,11 +248,11 @@
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 @@
// 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();
Modified: llvm/trunk/lib/VMCore/Verifier.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Verifier.cpp?rev=56005&r1=56004&r2=56005&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Verifier.cpp (original)
+++ llvm/trunk/lib/VMCore/Verifier.cpp Tue Sep 9 15:05:04 2008
@@ -394,7 +394,7 @@
&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);
More information about the llvm-commits
mailing list