diff options
author | Chris Lattner <sabre@nondot.org> | 2004-11-26 20:01:48 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2004-11-26 20:01:48 +0000 |
commit | 4e61676b568e6a30759d08073d174a0694dfea00 (patch) | |
tree | 3b0bc90407553c96e1ed7977004968d71bf27abe /lib/Analysis/BasicAliasAnalysis.cpp | |
parent | 0a1ac907c30cd3a5d0d8f96c1015bdb1c7461290 (diff) |
The trick with globals actually works with allocas and malloc too
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@18262 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Analysis/BasicAliasAnalysis.cpp')
-rw-r--r-- | lib/Analysis/BasicAliasAnalysis.cpp | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 3ab2744f07..b195b25cb5 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -290,13 +290,13 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size, if (!isa<Argument>(O1) && isa<ConstantPointerNull>(V2)) return NoAlias; // Unique values don't alias null - if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(O1)) - if (GV->getType()->getElementType()->isSized()) { + if (isa<GlobalVariable>(O1) || isa<AllocationInst>(O1)) + if (cast<PointerType>(O1->getType())->getElementType()->isSized()) { // If the size of the other access is larger than the total size of the - // global, it cannot be accessing the global (it's undefined to load or - // store bytes after the global). - unsigned GlobalSize = - getTargetData().getTypeSize(GV->getType()->getElementType()); + // global/alloca/malloc, it cannot be accessing the global (it's + // undefined to load or store bytes before or after an object). + const Type *ElTy = cast<PointerType>(O1->getType())->getElementType(); + unsigned GlobalSize = getTargetData().getTypeSize(ElTy); if (GlobalSize < V2Size) return NoAlias; } @@ -306,13 +306,13 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size, if (!isa<Argument>(O2) && isa<ConstantPointerNull>(V1)) return NoAlias; // Unique values don't alias null - if (const GlobalVariable *GV = dyn_cast<GlobalVariable>(O2)) - if (GV->getType()->getElementType()->isSized()) { + if (isa<GlobalVariable>(O2) || isa<AllocationInst>(O2)) + if (cast<PointerType>(O2->getType())->getElementType()->isSized()) { // If the size of the other access is larger than the total size of the - // global, it cannot be accessing the global (it's undefined to load or - // store bytes after the global). - unsigned GlobalSize = - getTargetData().getTypeSize(GV->getType()->getElementType()); + // global/alloca/malloc, it cannot be accessing the object (it's + // undefined to load or store bytes before or after an object). + const Type *ElTy = cast<PointerType>(O2->getType())->getElementType(); + unsigned GlobalSize = getTargetData().getTypeSize(ElTy); if (GlobalSize < V1Size) return NoAlias; } |