X-Git-Url: http://plrg.eecs.uci.edu/git/?p=oota-llvm.git;a=blobdiff_plain;f=lib%2FTransforms%2FIPO%2FFunctionAttrs.cpp;h=30c0b3a1763300d533698c5a6beade3cc8d22361;hp=ef72c99326eb72d81f47f543f1cab65aecae05da;hb=821e7c773781472bd1fa3fa34a4e8ff477f90548;hpb=69bfddd191c5148fa371e4075cd19cc30423122b diff --git a/lib/Transforms/IPO/FunctionAttrs.cpp b/lib/Transforms/IPO/FunctionAttrs.cpp index ef72c99326e..30c0b3a1763 100644 --- a/lib/Transforms/IPO/FunctionAttrs.cpp +++ b/lib/Transforms/IPO/FunctionAttrs.cpp @@ -60,63 +60,6 @@ struct FunctionAttrs : public CallGraphSCCPass { bool runOnSCC(CallGraphSCC &SCC) override; - bool AddReadAttrs(const CallGraphSCC &SCC); - 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); - - // Utility methods used by inferPrototypeAttributes to add attributes - // and maintain annotation statistics. - - void setDoesNotAccessMemory(Function &F) { - if (!F.doesNotAccessMemory()) { - F.setDoesNotAccessMemory(); - ++NumAnnotated; - } - } - - void setOnlyReadsMemory(Function &F) { - if (!F.onlyReadsMemory()) { - F.setOnlyReadsMemory(); - ++NumAnnotated; - } - } - - void setDoesNotThrow(Function &F) { - if (!F.doesNotThrow()) { - F.setDoesNotThrow(); - ++NumAnnotated; - } - } - - void setDoesNotCapture(Function &F, unsigned n) { - if (!F.doesNotCapture(n)) { - F.setDoesNotCapture(n); - ++NumAnnotated; - } - } - - void setOnlyReadsMemory(Function &F, unsigned n) { - if (!F.onlyReadsMemory(n)) { - F.setOnlyReadsMemory(n); - ++NumAnnotated; - } - } - - void setDoesNotAlias(Function &F, unsigned n) { - if (!F.doesNotAlias(n)) { - F.setDoesNotAlias(n); - ++NumAnnotated; - } - } - - bool inferPrototypeAttributes(Function &F); - - bool annotateLibraryCalls(const CallGraphSCC &SCC); - void getAnalysisUsage(AnalysisUsage &AU) const override { AU.setPreservesCFG(); AU.addRequired(); @@ -126,6 +69,16 @@ struct FunctionAttrs : public CallGraphSCCPass { private: TargetLibraryInfo *TLI; + + bool AddReadAttrs(const CallGraphSCC &SCC); + 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 inferPrototypeAttributes(Function &F); + bool annotateLibraryCalls(const CallGraphSCC &SCC); }; } @@ -984,6 +937,48 @@ bool FunctionAttrs::AddNonNullAttrs(const CallGraphSCC &SCC) { return MadeChange; } +static void setDoesNotAccessMemory(Function &F) { + if (!F.doesNotAccessMemory()) { + F.setDoesNotAccessMemory(); + ++NumAnnotated; + } +} + +static void setOnlyReadsMemory(Function &F) { + if (!F.onlyReadsMemory()) { + F.setOnlyReadsMemory(); + ++NumAnnotated; + } +} + +static void setDoesNotThrow(Function &F) { + if (!F.doesNotThrow()) { + F.setDoesNotThrow(); + ++NumAnnotated; + } +} + +static void setDoesNotCapture(Function &F, unsigned n) { + if (!F.doesNotCapture(n)) { + F.setDoesNotCapture(n); + ++NumAnnotated; + } +} + +static void setOnlyReadsMemory(Function &F, unsigned n) { + if (!F.onlyReadsMemory(n)) { + F.setOnlyReadsMemory(n); + ++NumAnnotated; + } +} + +static void setDoesNotAlias(Function &F, unsigned n) { + if (!F.doesNotAlias(n)) { + F.setDoesNotAlias(n); + ++NumAnnotated; + } +} + /// Analyze the name and prototype of the given function and set any applicable /// attributes. ///