diff options
| author | John Regehr <regehr@cs.utah.edu> | 2016-05-02 19:58:00 +0000 |
|---|---|---|
| committer | John Regehr <regehr@cs.utah.edu> | 2016-05-02 19:58:00 +0000 |
| commit | e1c481dccf6b3cd5b0b658af549dc5f92d37aa37 (patch) | |
| tree | f79aa76238f699c7340692e2e98ce2d1cc2c8c88 /llvm/lib/Analysis | |
| parent | 21b2c5660e3a741a516d382ee4230ba905b82784 (diff) | |
| download | bcm5719-llvm-e1c481dccf6b3cd5b0b658af549dc5f92d37aa37.tar.gz bcm5719-llvm-e1c481dccf6b3cd5b0b658af549dc5f92d37aa37.zip | |
[LVI] Add an API to LazyValueInfo so that it can export ConstantRanges
that it computes. Currently this is used for testing and precision
tuning, but it might be used by optimizations later.
Differential Revision: http://reviews.llvm.org/D19179
llvm-svn: 268291
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/LazyValueInfo.cpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp index cb1ad5e6525..cb26da55c87 100644 --- a/llvm/lib/Analysis/LazyValueInfo.cpp +++ b/llvm/lib/Analysis/LazyValueInfo.cpp @@ -1485,6 +1485,22 @@ Constant *LazyValueInfo::getConstant(Value *V, BasicBlock *BB, return nullptr; } +ConstantRange LazyValueInfo::getConstantRange(Value *V, BasicBlock *BB, + Instruction *CxtI) { + assert(V->getType()->isIntegerTy()); + unsigned Width = V->getType()->getIntegerBitWidth(); + const DataLayout &DL = BB->getModule()->getDataLayout(); + LVILatticeVal Result = + getCache(PImpl, AC, &DL, DT).getValueInBlock(V, BB, CxtI); + assert(!Result.isConstant()); + if (Result.isUndefined()) + return ConstantRange(Width, /*isFullSet=*/false); + if (Result.isConstantRange()) + return Result.getConstantRange(); + else + return ConstantRange(Width, /*isFullSet=*/true); +} + /// Determine whether the specified value is known to be a /// constant on the specified edge. Return null if not. Constant *LazyValueInfo::getConstantOnEdge(Value *V, BasicBlock *FromBB, |

