[Alignment][NFC] Use Align with TargetLowering::setMinFunctionAlignment
[llvm-core.git] / include / llvm / Transforms / IPO / FunctionAttrs.h
blobce61eea05c7998d32024fc9f1e2eaac7643091ee
1 //===- FunctionAttrs.h - Compute function attributes ------------*- C++ -*-===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8 //
9 /// \file
10 /// Provides passes for computing function attributes based on interprocedural
11 /// analyses.
13 //===----------------------------------------------------------------------===//
15 #ifndef LLVM_TRANSFORMS_IPO_FUNCTIONATTRS_H
16 #define LLVM_TRANSFORMS_IPO_FUNCTIONATTRS_H
18 #include "llvm/Analysis/CGSCCPassManager.h"
19 #include "llvm/Analysis/LazyCallGraph.h"
20 #include "llvm/IR/PassManager.h"
22 namespace llvm {
24 class AAResults;
25 class Function;
26 class Module;
27 class Pass;
29 /// The three kinds of memory access relevant to 'readonly' and
30 /// 'readnone' attributes.
31 enum MemoryAccessKind {
32 MAK_ReadNone = 0,
33 MAK_ReadOnly = 1,
34 MAK_MayWrite = 2,
35 MAK_WriteOnly = 3
38 /// Returns the memory access properties of this copy of the function.
39 MemoryAccessKind computeFunctionBodyMemoryAccess(Function &F, AAResults &AAR);
41 /// Computes function attributes in post-order over the call graph.
42 ///
43 /// By operating in post-order, this pass computes precise attributes for
44 /// called functions prior to processsing their callers. This "bottom-up"
45 /// approach allows powerful interprocedural inference of function attributes
46 /// like memory access patterns, etc. It can discover functions that do not
47 /// access memory, or only read memory, and give them the readnone/readonly
48 /// attribute. It also discovers function arguments that are not captured by
49 /// the function and marks them with the nocapture attribute.
50 struct PostOrderFunctionAttrsPass : PassInfoMixin<PostOrderFunctionAttrsPass> {
51 PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM,
52 LazyCallGraph &CG, CGSCCUpdateResult &UR);
55 /// Create a legacy pass manager instance of a pass to compute function attrs
56 /// in post-order.
57 Pass *createPostOrderFunctionAttrsLegacyPass();
59 /// A pass to do RPO deduction and propagation of function attributes.
60 ///
61 /// This pass provides a general RPO or "top down" propagation of
62 /// function attributes. For a few (rare) cases, we can deduce significantly
63 /// more about function attributes by working in RPO, so this pass
64 /// provides the complement to the post-order pass above where the majority of
65 /// deduction is performed.
66 // FIXME: Currently there is no RPO CGSCC pass structure to slide into and so
67 // this is a boring module pass, but eventually it should be an RPO CGSCC pass
68 // when such infrastructure is available.
69 class ReversePostOrderFunctionAttrsPass
70 : public PassInfoMixin<ReversePostOrderFunctionAttrsPass> {
71 public:
72 PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM);
75 } // end namespace llvm
77 #endif // LLVM_TRANSFORMS_IPO_FUNCTIONATTRS_H