diff options
author | Chris Lattner <sabre@nondot.org> | 2008-08-09 17:23:35 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-08-09 17:23:35 +0000 |
commit | 09e3b65a99e427fba1433ec338e6d708a81281d7 (patch) | |
tree | 2859efb70a38161954cc3bb06b7f209931773276 /llvm | |
parent | cbad725bf4c173c9ec645b295d555c5584eca7ae (diff) | |
download | bcm5719-llvm-09e3b65a99e427fba1433ec338e6d708a81281d7.tar.gz bcm5719-llvm-09e3b65a99e427fba1433ec338e6d708a81281d7.zip |
"This patch adds a virtual call to AbstractLatticeFunction to derive a
type lattice value for an Argument*, giving clients the opportunity to
use something other than Top for it if they choose to."
Patch by John McCall!
llvm-svn: 54589
Diffstat (limited to 'llvm')
-rw-r--r-- | llvm/include/llvm/Analysis/SparsePropagation.h | 7 | ||||
-rw-r--r-- | llvm/lib/Analysis/SparsePropagation.cpp | 4 |
2 files changed, 10 insertions, 1 deletions
diff --git a/llvm/include/llvm/Analysis/SparsePropagation.h b/llvm/include/llvm/Analysis/SparsePropagation.h index bc9ae6172b8..a054c76c9bc 100644 --- a/llvm/include/llvm/Analysis/SparsePropagation.h +++ b/llvm/include/llvm/Analysis/SparsePropagation.h @@ -24,6 +24,7 @@ namespace llvm { class Value; class Constant; + class Argument; class Instruction; class PHINode; class TerminatorInst; @@ -75,6 +76,12 @@ public: virtual Constant *GetConstant(LatticeVal LV, Value *Val, SparseSolver &SS) { return 0; } + + /// ComputeArgument - Given a formal argument value, compute and return a + /// lattice value corresponding to the specified argument. + virtual LatticeVal ComputeArgument(Argument *I) { + return getOverdefinedVal(); // always safe + } /// MergeValues - Compute and return the merge of the two specified lattice /// values. Merging should only move one direction down the lattice to diff --git a/llvm/lib/Analysis/SparsePropagation.cpp b/llvm/lib/Analysis/SparsePropagation.cpp index 2fda64c7335..8f042c27839 100644 --- a/llvm/lib/Analysis/SparsePropagation.cpp +++ b/llvm/lib/Analysis/SparsePropagation.cpp @@ -57,8 +57,10 @@ SparseSolver::LatticeVal SparseSolver::getOrInitValueState(Value *V) { return LatticeFunc->getUntrackedVal(); else if (Constant *C = dyn_cast<Constant>(V)) LV = LatticeFunc->ComputeConstant(C); + else if (Argument *A = dyn_cast<Argument>(V)) + LV = LatticeFunc->ComputeArgument(A); else if (!isa<Instruction>(V)) - // Non-instructions (e.g. formal arguments) are overdefined. + // All other non-instructions are overdefined. LV = LatticeFunc->getOverdefinedVal(); else // All instructions are underdefined by default. |