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 | 194ae9de3398987861d4ece7ee36757024bde9f9 (patch) | |
tree | cd8f69bf4c7c1540cd961301e48eac770138549d /lib | |
parent | 45513343997ecc59dce2848cb509bb100e8746dd (diff) | |
download | external_llvm-194ae9de3398987861d4ece7ee36757024bde9f9.zip external_llvm-194ae9de3398987861d4ece7ee36757024bde9f9.tar.gz external_llvm-194ae9de3398987861d4ece7ee36757024bde9f9.tar.bz2 |
Some minor optimizations for isObjectSmallerThan.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60687 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r-- | lib/Analysis/BasicAliasAnalysis.cpp | 19 |
1 files changed, 12 insertions, 7 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 5b65fb1..1604374 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/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; } |