From c1820036bdedea566c89d2bd47bbbbe4384bdc73 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Sat, 20 Sep 2003 03:08:47 +0000 Subject: [PATCH] Fix bug: BasicAA/2003-09-19-LocalArgument.ll git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@8615 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Analysis/BasicAliasAnalysis.cpp | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 54614d76f9d..9aa885e9ef1 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -8,6 +8,7 @@ #include "llvm/Analysis/AliasAnalysis.h" #include "llvm/Pass.h" +#include "llvm/Argument.h" #include "llvm/iMemory.h" #include "llvm/iOther.h" #include "llvm/ConstantHandling.h" @@ -54,16 +55,20 @@ void BasicAliasAnalysis::initializePass() { -// hasUniqueAddress - Return true if the +// hasUniqueAddress - Return true if the specified value points to something +// with a unique, discernable, address. static inline bool hasUniqueAddress(const Value *V) { - return isa(V) || isa(V) || isa(V); + return isa(V) || isa(V); } +// getUnderlyingObject - This traverses the use chain to figure out what object +// the specified value points to. If the value points to, or is derived from, a +// unique object or an argument, return it. static const Value *getUnderlyingObject(const Value *V) { if (!isa(V->getType())) return 0; // If we are at some type of object... return it. - if (hasUniqueAddress(V)) return V; + if (hasUniqueAddress(V) || isa(V)) return V; // Traverse through different addressing mechanisms... if (const Instruction *I = dyn_cast(V)) { @@ -112,16 +117,26 @@ BasicAliasAnalysis::alias(const Value *V1, unsigned V1Size, // Pointing at a discernible object? if (O1 && O2) { - // If they are two different objects, we know that we have no alias... - if (O1 != O2) return NoAlias; + if (isa(O1)) { + // Incoming argument cannot alias locally allocated object! + if (isa(O2)) return NoAlias; + // Otherwise, nothing is known... + } else if (isa(O2)) { + // Incoming argument cannot alias locally allocated object! + if (isa(O1)) return NoAlias; + // Otherwise, nothing is known... + } else { + // If they are two different objects, we know that we have no alias... + if (O1 != O2) return NoAlias; + } // If they are the same object, they we can look at the indexes. If they // index off of the object is the same for both pointers, they must alias. // If they are provably different, they must not alias. Otherwise, we can't // tell anything. - } else if (O1 && isa(V2)) { + } else if (O1 && !isa(O1) && isa(V2)) { return NoAlias; // Unique values don't alias null - } else if (O2 && isa(V1)) { + } else if (O2 && !isa(O2) && isa(V1)) { return NoAlias; // Unique values don't alias null } -- 2.34.1