[PATCH] D29695: FunctionAttrs: Factor out a function for querying memory access of a specific copy of a function. NFC.

Peter Collingbourne via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Feb 7 17:16:41 PST 2017


pcc created this revision.

This will later be used by ThinLTOBitcodeWriter to add copies of readnone
functions to the regular LTO module.


https://reviews.llvm.org/D29695

Files:
  llvm/include/llvm/Transforms/IPO/FunctionAttrs.h
  llvm/lib/Transforms/IPO/FunctionAttrs.cpp


Index: llvm/lib/Transforms/IPO/FunctionAttrs.cpp
===================================================================
--- llvm/lib/Transforms/IPO/FunctionAttrs.cpp
+++ llvm/lib/Transforms/IPO/FunctionAttrs.cpp
@@ -49,20 +49,6 @@
 STATISTIC(NumNonNullReturn, "Number of function returns marked nonnull");
 STATISTIC(NumNoRecurse, "Number of functions marked as norecurse");
 
-namespace {
-typedef SmallSetVector<Function *, 8> SCCNodeSet;
-}
-
-namespace {
-/// The three kinds of memory access relevant to 'readonly' and
-/// 'readnone' attributes.
-enum MemoryAccessKind {
-  MAK_ReadNone = 0,
-  MAK_ReadOnly = 1,
-  MAK_MayWrite = 2
-};
-}
-
 static MemoryAccessKind checkFunctionMemoryAccess(Function &F, AAResults &AAR,
                                                   const SCCNodeSet &SCCNodes) {
   FunctionModRefBehavior MRB = AAR.getModRefBehavior(&F);
@@ -81,6 +67,12 @@
     return MAK_MayWrite;
   }
 
+  return computeFunctionBodyMemoryAccess(F, AAR, SCCNodes);
+}
+
+MemoryAccessKind
+llvm::computeFunctionBodyMemoryAccess(Function &F, AAResults &AAR,
+                                      const SCCNodeSet &SCCNodes) {
   // Scan the function body for instructions that may read or write memory.
   bool ReadsMemory = false;
   for (inst_iterator II = inst_begin(F), E = inst_end(F); II != E; ++II) {
Index: llvm/include/llvm/Transforms/IPO/FunctionAttrs.h
===================================================================
--- llvm/include/llvm/Transforms/IPO/FunctionAttrs.h
+++ llvm/include/llvm/Transforms/IPO/FunctionAttrs.h
@@ -20,6 +20,23 @@
 
 namespace llvm {
 
+class AAResults;
+
+typedef SmallSetVector<Function *, 8> SCCNodeSet;
+
+/// The three kinds of memory access relevant to 'readonly' and
+/// 'readnone' attributes.
+enum MemoryAccessKind {
+  MAK_ReadNone = 0,
+  MAK_ReadOnly = 1,
+  MAK_MayWrite = 2
+};
+
+/// Returns the memory access properties of this copy of the function.
+MemoryAccessKind
+computeFunctionBodyMemoryAccess(Function &F, AAResults &AAR,
+                                const SCCNodeSet &SCCNodes);
+
 /// Computes function attributes in post-order over the call graph.
 ///
 /// By operating in post-order, this pass computes precise attributes for


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D29695.87568.patch
Type: text/x-patch
Size: 2215 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170208/19b6f817/attachment.bin>


More information about the llvm-commits mailing list