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 | 295d4e953a1214f60632220b9fcb31c1af8b0c27 (patch) | |
tree | cd8f69bf4c7c1540cd961301e48eac770138549d /lib/Analysis/BasicAliasAnalysis.cpp | |
parent | fb4b58c9aadeedb675e000d5654201a7e2ae843d (diff) |
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/Analysis/BasicAliasAnalysis.cpp')
-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 5b65fb1199..1604374ada 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; } |