[llvm] r247521 - [FunctionAttrs] Collect utility functions as static helpers rather than
Chandler Carruth via llvm-commits
llvm-commits at lists.llvm.org
Sun Sep 13 00:50:43 PDT 2015
Author: chandlerc
Date: Sun Sep 13 02:50:43 2015
New Revision: 247521
URL: http://llvm.org/viewvc/llvm-project?rev=247521&view=rev
Log:
[FunctionAttrs] Collect utility functions as static helpers rather than
methods. They don't need anything from the class anyways.
Also, collect the declarations into the private section of the pass.
Modified:
llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
Modified: llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp?rev=247521&r1=247520&r2=247521&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp (original)
+++ llvm/trunk/lib/Transforms/IPO/FunctionAttrs.cpp Sun Sep 13 02:50:43 2015
@@ -60,63 +60,6 @@ struct FunctionAttrs : public CallGraphS
bool runOnSCC(CallGraphSCC &SCC) override;
- bool AddReadAttrs(const CallGraphSCC &SCC);
- bool AddArgumentAttrs(const CallGraphSCC &SCC);
- bool IsFunctionMallocLike(Function *F, SmallPtrSet<Function *, 8> &) const;
- bool AddNoAliasAttrs(const CallGraphSCC &SCC);
- bool ReturnsNonNull(Function *F, SmallPtrSet<Function *, 8> &,
- 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<AssumptionCacheTracker>();
@@ -126,6 +69,16 @@ struct FunctionAttrs : public CallGraphS
private:
TargetLibraryInfo *TLI;
+
+ bool AddReadAttrs(const CallGraphSCC &SCC);
+ bool AddArgumentAttrs(const CallGraphSCC &SCC);
+ bool IsFunctionMallocLike(Function *F, SmallPtrSet<Function *, 8> &) const;
+ bool AddNoAliasAttrs(const CallGraphSCC &SCC);
+ bool ReturnsNonNull(Function *F, SmallPtrSet<Function *, 8> &,
+ bool &Speculative) const;
+ bool AddNonNullAttrs(const CallGraphSCC &SCC);
+ bool inferPrototypeAttributes(Function &F);
+ bool annotateLibraryCalls(const CallGraphSCC &SCC);
};
}
@@ -984,6 +937,48 @@ bool FunctionAttrs::AddNonNullAttrs(cons
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.
///
More information about the llvm-commits
mailing list