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 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 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 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) {