diff options
| author | Philip Reames <listmail@philipreames.com> | 2016-12-06 03:22:03 +0000 |
|---|---|---|
| committer | Philip Reames <listmail@philipreames.com> | 2016-12-06 03:22:03 +0000 |
| commit | 05c435e3a4caf261f978c588aeee5945d4e6bbd1 (patch) | |
| tree | 2ae376502c9f09581c77e3888380a902d561e148 /llvm/lib | |
| parent | 1baaef138dc0328492ae81d9fad7e37ff740dcbb (diff) | |
| download | bcm5719-llvm-05c435e3a4caf261f978c588aeee5945d4e6bbd1.tar.gz bcm5719-llvm-05c435e3a4caf261f978c588aeee5945d4e6bbd1.zip | |
[LVI] Extract a helper function
Extracting a helper function out of solveBlockValue makes the contract around the cache much easier to understand.
llvm-svn: 288766
Diffstat (limited to 'llvm/lib')
| -rw-r--r-- | llvm/lib/Analysis/LazyValueInfo.cpp | 54 |
1 files changed, 22 insertions, 32 deletions
diff --git a/llvm/lib/Analysis/LazyValueInfo.cpp b/llvm/lib/Analysis/LazyValueInfo.cpp index 5ea0e7ce9fb..6bce7c6d35e 100644 --- a/llvm/lib/Analysis/LazyValueInfo.cpp +++ b/llvm/lib/Analysis/LazyValueInfo.cpp @@ -623,6 +623,7 @@ namespace { // returned means that the work item was not completely processed and must // be revisited after going through the new items. bool solveBlockValue(Value *Val, BasicBlock *BB); + bool solveBlockValueImpl(LVILatticeVal &Res, Value *Val, BasicBlock *BB); bool solveBlockValueNonLocal(LVILatticeVal &BBLV, Value *Val, BasicBlock *BB); bool solveBlockValuePHINode(LVILatticeVal &BBLV, PHINode *PN, BasicBlock *BB); bool solveBlockValueSelect(LVILatticeVal &BBLV, SelectInst *S, @@ -747,28 +748,26 @@ bool LazyValueInfoImpl::solveBlockValue(Value *Val, BasicBlock *BB) { // Hold off inserting this value into the Cache in case we have to return // false and come back later. LVILatticeVal Res; + if (!solveBlockValueImpl(Res, Val, BB)) + // Work pushed, will revisit + return false; + + TheCache.insertResult(Val, BB, Res); + return true; +} + +bool LazyValueInfoImpl::solveBlockValueImpl(LVILatticeVal &Res, + Value *Val, BasicBlock *BB) { Instruction *BBI = dyn_cast<Instruction>(Val); - if (!BBI || BBI->getParent() != BB) { - if (!solveBlockValueNonLocal(Res, Val, BB)) - return false; - TheCache.insertResult(Val, BB, Res); - return true; - } + if (!BBI || BBI->getParent() != BB) + return solveBlockValueNonLocal(Res, Val, BB); - if (PHINode *PN = dyn_cast<PHINode>(BBI)) { - if (!solveBlockValuePHINode(Res, PN, BB)) - return false; - TheCache.insertResult(Val, BB, Res); - return true; - } + if (PHINode *PN = dyn_cast<PHINode>(BBI)) + return solveBlockValuePHINode(Res, PN, BB); - if (auto *SI = dyn_cast<SelectInst>(BBI)) { - if (!solveBlockValueSelect(Res, SI, BB)) - return false; - TheCache.insertResult(Val, BB, Res); - return true; - } + if (auto *SI = dyn_cast<SelectInst>(BBI)) + return solveBlockValueSelect(Res, SI, BB); // If this value is a nonnull pointer, record it's range and bailout. Note // that for all other pointer typed values, we terminate the search at the @@ -782,29 +781,20 @@ bool LazyValueInfoImpl::solveBlockValue(Value *Val, BasicBlock *BB) { PointerType *PT = dyn_cast<PointerType>(BBI->getType()); if (PT && isKnownNonNull(BBI)) { Res = LVILatticeVal::getNot(ConstantPointerNull::get(PT)); - TheCache.insertResult(Val, BB, Res); return true; } if (BBI->getType()->isIntegerTy()) { - if (isa<CastInst>(BBI)) { - if (!solveBlockValueCast(Res, BBI, BB)) - return false; - TheCache.insertResult(Val, BB, Res); - return true; - } + if (isa<CastInst>(BBI)) + return solveBlockValueCast(Res, BBI, BB); + BinaryOperator *BO = dyn_cast<BinaryOperator>(BBI); - if (BO && isa<ConstantInt>(BO->getOperand(1))) { - if (!solveBlockValueBinaryOp(Res, BBI, BB)) - return false; - TheCache.insertResult(Val, BB, Res); - return true; - } + if (BO && isa<ConstantInt>(BO->getOperand(1))) + return solveBlockValueBinaryOp(Res, BBI, BB); } DEBUG(dbgs() << " compute BB '" << BB->getName() << "' - unknown inst def found.\n"); Res = getFromRangeMetadata(BBI); - TheCache.insertResult(Val, BB, Res); return true; } |

