X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=lib%2FTransforms%2FIPO%2FFunctionAttrs.cpp;h=cfeedf6d1db999cfeefb66540f01a8f29523882e;hp=3ea54687365c1fb44c6a85eccdc60ad33e70079b;hb=1f97273f8fb2e51080ef2c7a9cd867d0d0ccf8a0;hpb=b21635658f4b9b7c7e28ff035e731903545646f0 diff --git a/lib/Transforms/IPO/FunctionAttrs.cpp b/lib/Transforms/IPO/FunctionAttrs.cpp index 3ea54687365..cfeedf6d1db 100644 --- a/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/lib/Transforms/IPO/FunctionAttrs.cpp @@ -74,8 +74,6 @@ private: bool AddArgumentAttrs(const CallGraphSCC &SCC); bool IsFunctionMallocLike(Function *F, SmallPtrSet &) const; bool AddNoAliasAttrs(const CallGraphSCC &SCC); - bool ReturnsNonNull(Function *F, SmallPtrSet &, - bool &Speculative) const; bool AddNonNullAttrs(const CallGraphSCC &SCC); bool annotateLibraryCalls(const CallGraphSCC &SCC); }; @@ -798,9 +796,14 @@ bool FunctionAttrs::AddNoAliasAttrs(const CallGraphSCC &SCC) { } /// Tests whether this function is known to not return null. -bool FunctionAttrs::ReturnsNonNull(Function *F, - SmallPtrSet &SCCNodes, - bool &Speculative) const { +/// +/// Requires that the function returns a pointer. +/// +/// Returns true if it believes the function will not return a null, and sets +/// \p Speculative based on whether the returned conclusion is a speculative +/// conclusion due to SCC calls. +static bool isReturnNonNull(Function *F, SmallPtrSet &SCCNodes, + const TargetLibraryInfo &TLI, bool &Speculative) { assert(F->getReturnType()->isPointerTy() && "nonnull only meaningful on pointer types"); Speculative = false; @@ -814,7 +817,7 @@ bool FunctionAttrs::ReturnsNonNull(Function *F, Value *RetVal = FlowsToReturn[i]; // If this value is locally known to be non-null, we're good - if (isKnownNonNull(RetVal, TLI)) + if (isKnownNonNull(RetVal, &TLI)) continue; // Otherwise, we need to look upwards since we can't make any local @@ -902,7 +905,7 @@ bool FunctionAttrs::AddNonNullAttrs(const CallGraphSCC &SCC) { continue; bool Speculative = false; - if (ReturnsNonNull(F, SCCNodes, Speculative)) { + if (isReturnNonNull(F, SCCNodes, *TLI, Speculative)) { if (!Speculative) { // Mark the function eagerly since we may discover a function // which prevents us from speculating about the entire SCC