diff --git a/lib/Analysis/BasicAliasAnalysis.cpp b/lib/Analysis/BasicAliasAnalysis.cpp index 6ab7d941ee3..8f7fcbf67a8 100644 --- a/lib/Analysis/BasicAliasAnalysis.cpp +++ b/lib/Analysis/BasicAliasAnalysis.cpp @@ -320,11 +320,15 @@ static bool isKnownNonNull(const Value *V) { /// isNonEscapingLocalObject - Return true if the pointer is to a function-local /// object that never escapes from the function. static bool isNonEscapingLocalObject(const Value *V) { - // If this is a local allocation or byval argument, check to see if it - // escapes. - if (isa(V) || - (isa(V) && cast(V)->hasByValAttr())) + // If this is a local allocation, check to see if it escapes. + if (isa(V)) return !AddressMightEscape(V); + + // If this is an argument that corresponds to a byval or noalias argument, + // it can't escape either. + if (const Argument *A = dyn_cast(V)) + if (A->hasByValAttr() || A->hasNoAliasAttr()) + return !AddressMightEscape(V); return false; }