Some minor optimizations for isObjectSmallerThan.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60687 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Chris Lattner 2008-12-08 06:28:54 +00:00
parent fb4b58c9aa
commit 295d4e953a

View File

@ -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;
}