From 4e61676b568e6a30759d08073d174a0694dfea00 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Fri, 26 Nov 2004 20:01:48 +0000 Subject: [PATCH] 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 --- lib/Analysis/BasicAliasAnalysis.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 3ab2744f07c..b195b25cb5b 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -290,13 +290,13 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size, if (!isa(O1) && isa(V2)) return NoAlias; // Unique values don't alias null - if (const GlobalVariable *GV = dyn_cast(O1)) - if (GV->getType()->getElementType()->isSized()) { + if (isa(O1) || isa(O1)) + if (cast(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(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(O2) && isa(V1)) return NoAlias; // Unique values don't alias null - if (const GlobalVariable *GV = dyn_cast(O2)) - if (GV->getType()->getElementType()->isSized()) { + if (isa(O2) || isa(O2)) + if (cast(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(O2->getType())->getElementType(); + unsigned GlobalSize = getTargetData().getTypeSize(ElTy); if (GlobalSize < V1Size) return NoAlias; } -- 2.34.1