diff options
| author | Chris Lattner <sabre@nondot.org> | 2008-12-08 06:28:54 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2008-12-08 06:28:54 +0000 |
| commit | 2f9d8458c83421e5c33717f0605541bc700d091f (patch) | |
| tree | df599ffffea9484a36c09d2e92eb7213b74dbff9 /llvm/lib/Analysis | |
| parent | 8df5083bb4d5b87cc41ede509516a496feab6155 (diff) | |
| download | bcm5719-llvm-2f9d8458c83421e5c33717f0605541bc700d091f.tar.gz bcm5719-llvm-2f9d8458c83421e5c33717f0605541bc700d091f.zip | |
Some minor optimizations for isObjectSmallerThan.
llvm-svn: 60687
Diffstat (limited to 'llvm/lib/Analysis')
| -rw-r--r-- | llvm/lib/Analysis/BasicAliasAnalysis.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/llvm/lib/Analysis/BasicAliasAnalysis.cpp b/llvm/lib/Analysis/BasicAliasAnalysis.cpp index 5b65fb1199c..1604374adaf 100644 --- a/llvm/lib/Analysis/BasicAliasAnalysis.cpp +++ b/llvm/lib/Analysis/BasicAliasAnalysis.cpp @@ -164,19 +164,24 @@ static bool isNonEscapingLocalObject(const Value *V) { /// by V is smaller than Size. static bool isObjectSmallerThan(const Value *V, unsigned Size, const TargetData &TD) { - const Type *AccessTy = 0; - if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) + const Type *AccessTy; + if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(V)) { AccessTy = GV->getType()->getElementType(); - - if (const AllocationInst *AI = dyn_cast<AllocationInst>(V)) + } else if (const AllocationInst *AI = dyn_cast<AllocationInst>(V)) { if (!AI->isArrayAllocation()) AccessTy = AI->getType()->getElementType(); - - if (const Argument *A = dyn_cast<Argument>(V)) + else + return false; + } else if (const Argument *A = dyn_cast<Argument>(V)) { if (A->hasByValAttr()) AccessTy = cast<PointerType>(A->getType())->getElementType(); + else + return false; + } else { + return false; + } - if (AccessTy && AccessTy->isSized()) + if (AccessTy->isSized()) return TD.getABITypeSize(AccessTy) < Size; return false; } |

