[llvm] r192906 - Simplify the interface of AnalyzeGlobal a bit and rename to analyzeGlobal.
Rafael Espindola
rafael.espindola at gmail.com
Thu Oct 17 11:00:25 PDT 2013
Author: rafael
Date: Thu Oct 17 13:00:25 2013
New Revision: 192906
URL: http://llvm.org/viewvc/llvm-project?rev=192906&view=rev
Log:
Simplify the interface of AnalyzeGlobal a bit and rename to analyzeGlobal.
No functionality change.
Modified:
llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
Modified: llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp?rev=192906&r1=192905&r2=192906&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/GlobalOpt.cpp Thu Oct 17 13:00:25 2013
@@ -184,13 +184,8 @@ static bool SafeToDestroyConstant(const
return true;
}
-
-/// AnalyzeGlobal - Look at all uses of the global and fill in the GlobalStatus
-/// structure. If the global has its address taken, return true to indicate we
-/// can't do anything with it.
-///
-static bool AnalyzeGlobal(const Value *V, GlobalStatus &GS,
- SmallPtrSet<const PHINode*, 16> &PHIUsers) {
+static bool analyzeGlobalAux(const Value *V, GlobalStatus &GS,
+ SmallPtrSet<const PHINode *, 16> &PHIUsers) {
for (Value::const_use_iterator UI = V->use_begin(), E = V->use_end(); UI != E;
++UI) {
const User *U = *UI;
@@ -201,7 +196,8 @@ static bool AnalyzeGlobal(const Value *V
// know to expect it in various places. Just reject early.
if (!isa<PointerType>(CE->getType())) return true;
- if (AnalyzeGlobal(CE, GS, PHIUsers)) return true;
+ if (analyzeGlobalAux(CE, GS, PHIUsers))
+ return true;
} else if (const Instruction *I = dyn_cast<Instruction>(U)) {
if (!GS.HasMultipleAccessingFunctions) {
const Function *F = I->getParent()->getParent();
@@ -260,16 +256,20 @@ static bool AnalyzeGlobal(const Value *V
}
}
} else if (isa<BitCastInst>(I)) {
- if (AnalyzeGlobal(I, GS, PHIUsers)) return true;
+ if (analyzeGlobalAux(I, GS, PHIUsers))
+ return true;
} else if (isa<GetElementPtrInst>(I)) {
- if (AnalyzeGlobal(I, GS, PHIUsers)) return true;
+ if (analyzeGlobalAux(I, GS, PHIUsers))
+ return true;
} else if (isa<SelectInst>(I)) {
- if (AnalyzeGlobal(I, GS, PHIUsers)) return true;
+ if (analyzeGlobalAux(I, GS, PHIUsers))
+ return true;
} else if (const PHINode *PN = dyn_cast<PHINode>(I)) {
// PHI nodes we can check just like select or GEP instructions, but we
// have to be careful about infinite recursion.
if (PHIUsers.insert(PN)) // Not already visited.
- if (AnalyzeGlobal(I, GS, PHIUsers)) return true;
+ if (analyzeGlobalAux(I, GS, PHIUsers))
+ return true;
} else if (isa<CmpInst>(I)) {
GS.isCompared = true;
} else if (const MemTransferInst *MTI = dyn_cast<MemTransferInst>(I)) {
@@ -300,6 +300,15 @@ static bool AnalyzeGlobal(const Value *V
return false;
}
+/// Look at all uses of the global and fill in the GlobalStatus
+/// structure. If the global has its address taken, return true to indicate we
+/// can't do anything with it.
+///
+static bool analyzeGlobal(const Value *V, GlobalStatus &GS) {
+ SmallPtrSet<const PHINode *, 16> PHIUsers;
+ return analyzeGlobalAux(V, GS, PHIUsers);
+}
+
/// isLeakCheckerRoot - Is this global variable possibly used by a leak checker
/// as a root? If so, we might not really want to eliminate the stores to it.
static bool isLeakCheckerRoot(GlobalVariable *GV) {
@@ -1916,10 +1925,9 @@ bool GlobalOpt::ProcessGlobal(GlobalVari
if (!GV->hasLocalLinkage())
return false;
- SmallPtrSet<const PHINode*, 16> PHIUsers;
GlobalStatus GS;
- if (AnalyzeGlobal(GV, GS, PHIUsers))
+ if (analyzeGlobal(GV, GS))
return false;
if (!GS.isCompared && !GV->hasUnnamedAddr()) {
More information about the llvm-commits
mailing list