|
|
|||
File indexing completed on 2026-05-10 08:44:40
0001 //===- FunctionAttrs.h - Compute function attributes ------------*- C++ -*-===// 0002 // 0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 0004 // See https://llvm.org/LICENSE.txt for license information. 0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 0006 // 0007 //===----------------------------------------------------------------------===// 0008 // 0009 /// \file 0010 /// Provides passes for computing function attributes based on interprocedural 0011 /// analyses. 0012 // 0013 //===----------------------------------------------------------------------===// 0014 0015 #ifndef LLVM_TRANSFORMS_IPO_FUNCTIONATTRS_H 0016 #define LLVM_TRANSFORMS_IPO_FUNCTIONATTRS_H 0017 0018 #include "llvm/Analysis/AliasAnalysis.h" 0019 #include "llvm/Analysis/CGSCCPassManager.h" 0020 #include "llvm/Analysis/LazyCallGraph.h" 0021 #include "llvm/IR/PassManager.h" 0022 0023 namespace llvm { 0024 0025 class GlobalValueSummary; 0026 class ModuleSummaryIndex; 0027 class Function; 0028 class Module; 0029 0030 /// Returns the memory access properties of this copy of the function. 0031 MemoryEffects computeFunctionBodyMemoryAccess(Function &F, AAResults &AAR); 0032 0033 /// Propagate function attributes for function summaries along the index's 0034 /// callgraph during thinlink 0035 bool thinLTOPropagateFunctionAttrs( 0036 ModuleSummaryIndex &Index, 0037 function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)> 0038 isPrevailing); 0039 0040 /// Computes function attributes in post-order over the call graph. 0041 /// 0042 /// By operating in post-order, this pass computes precise attributes for 0043 /// called functions prior to processsing their callers. This "bottom-up" 0044 /// approach allows powerful interprocedural inference of function attributes 0045 /// like memory access patterns, etc. It can discover functions that do not 0046 /// access memory, or only read memory, and give them the readnone/readonly 0047 /// attribute. It also discovers function arguments that are not captured by 0048 /// the function and marks them with the nocapture attribute. 0049 struct PostOrderFunctionAttrsPass : PassInfoMixin<PostOrderFunctionAttrsPass> { 0050 PostOrderFunctionAttrsPass(bool SkipNonRecursive = false) 0051 : SkipNonRecursive(SkipNonRecursive) {} 0052 PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, 0053 LazyCallGraph &CG, CGSCCUpdateResult &UR); 0054 0055 void printPipeline(raw_ostream &OS, 0056 function_ref<StringRef(StringRef)> MapClassName2PassName); 0057 0058 private: 0059 bool SkipNonRecursive; 0060 }; 0061 0062 /// A pass to do RPO deduction and propagation of function attributes. 0063 /// 0064 /// This pass provides a general RPO or "top down" propagation of 0065 /// function attributes. For a few (rare) cases, we can deduce significantly 0066 /// more about function attributes by working in RPO, so this pass 0067 /// provides the complement to the post-order pass above where the majority of 0068 /// deduction is performed. 0069 // FIXME: Currently there is no RPO CGSCC pass structure to slide into and so 0070 // this is a boring module pass, but eventually it should be an RPO CGSCC pass 0071 // when such infrastructure is available. 0072 class ReversePostOrderFunctionAttrsPass 0073 : public PassInfoMixin<ReversePostOrderFunctionAttrsPass> { 0074 public: 0075 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM); 0076 }; 0077 0078 } // end namespace llvm 0079 0080 #endif // LLVM_TRANSFORMS_IPO_FUNCTIONATTRS_H
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|