LLVM
8.0.1
include
llvm
Transforms
IPO
FunctionAttrs.h
Go to the documentation of this file.
1
//===- FunctionAttrs.h - Compute function attributes ------------*- C++ -*-===//
2
//
3
// The LLVM Compiler Infrastructure
4
//
5
// This file is distributed under the University of Illinois Open Source
6
// License. See LICENSE.TXT for details.
7
//
8
//===----------------------------------------------------------------------===//
9
//
10
/// \file
11
/// Provides passes for computing function attributes based on interprocedural
12
/// analyses.
13
//
14
//===----------------------------------------------------------------------===//
15
16
#ifndef LLVM_TRANSFORMS_IPO_FUNCTIONATTRS_H
17
#define LLVM_TRANSFORMS_IPO_FUNCTIONATTRS_H
18
19
#include "
llvm/Analysis/CGSCCPassManager.h
"
20
#include "
llvm/Analysis/LazyCallGraph.h
"
21
#include "
llvm/IR/PassManager.h
"
22
23
namespace
llvm
{
24
25
class
AAResults;
26
class
Function
;
27
class
Module;
28
class
Pass
;
29
30
/// The three kinds of memory access relevant to 'readonly' and
31
/// 'readnone' attributes.
32
enum
MemoryAccessKind
{
33
MAK_ReadNone
= 0,
34
MAK_ReadOnly
= 1,
35
MAK_MayWrite
= 2,
36
MAK_WriteOnly
= 3
37
};
38
39
/// Returns the memory access properties of this copy of the function.
40
MemoryAccessKind
computeFunctionBodyMemoryAccess
(
Function
&
F
,
AAResults
&AAR);
41
42
/// Computes function attributes in post-order over the call graph.
43
///
44
/// By operating in post-order, this pass computes precise attributes for
45
/// called functions prior to processsing their callers. This "bottom-up"
46
/// approach allows powerful interprocedural inference of function attributes
47
/// like memory access patterns, etc. It can discover functions that do not
48
/// access memory, or only read memory, and give them the readnone/readonly
49
/// attribute. It also discovers function arguments that are not captured by
50
/// the function and marks them with the nocapture attribute.
51
struct
PostOrderFunctionAttrsPass
:
PassInfoMixin
<PostOrderFunctionAttrsPass> {
52
PreservedAnalyses
run
(
LazyCallGraph::SCC
&
C
,
CGSCCAnalysisManager
&AM,
53
LazyCallGraph
&CG,
CGSCCUpdateResult
&UR);
54
};
55
56
/// Create a legacy pass manager instance of a pass to compute function attrs
57
/// in post-order.
58
Pass
*
createPostOrderFunctionAttrsLegacyPass
();
59
60
/// A pass to do RPO deduction and propagation of function attributes.
61
///
62
/// This pass provides a general RPO or "top down" propagation of
63
/// function attributes. For a few (rare) cases, we can deduce significantly
64
/// more about function attributes by working in RPO, so this pass
65
/// provides the complement to the post-order pass above where the majority of
66
/// deduction is performed.
67
// FIXME: Currently there is no RPO CGSCC pass structure to slide into and so
68
// this is a boring module pass, but eventually it should be an RPO CGSCC pass
69
// when such infrastructure is available.
70
class
ReversePostOrderFunctionAttrsPass
71
:
public
PassInfoMixin
<ReversePostOrderFunctionAttrsPass> {
72
public
:
73
PreservedAnalyses
run
(
Module
&M,
ModuleAnalysisManager
&AM);
74
};
75
76
}
// end namespace llvm
77
78
#endif // LLVM_TRANSFORMS_IPO_FUNCTIONATTRS_H
llvm::Pass
Pass interface - Implemented by all 'passes'.
Definition:
Pass.h:81
C
uint64_t CallInst * C
Definition:
NVVMIntrRange.cpp:67
llvm::PostOrderFunctionAttrsPass
Computes function attributes in post-order over the call graph.
Definition:
FunctionAttrs.h:51
llvm::MemoryAccessKind
MemoryAccessKind
The three kinds of memory access relevant to 'readonly' and 'readnone' attributes.
Definition:
FunctionAttrs.h:32
llvm
This class represents lattice values for constants.
Definition:
AllocatorList.h:24
llvm::Module
A Module instance is used to store all the information related to an LLVM module. ...
Definition:
Module.h:65
LazyCallGraph.h
Implements a lazy call graph analysis and related passes for the new pass manager.
llvm::codeview::PublicSymFlags::Function
F
F(f)
llvm::Function
Definition:
Function.h:60
llvm::computeFunctionBodyMemoryAccess
MemoryAccessKind computeFunctionBodyMemoryAccess(Function &F, AAResults &AAR)
Returns the memory access properties of this copy of the function.
Definition:
FunctionAttrs.cpp:224
llvm::CGSCCUpdateResult
Support structure for SCC passes to communicate updates the call graph back to the CGSCC pass manager...
Definition:
CGSCCPassManager.h:232
llvm::ReversePostOrderFunctionAttrsPass
A pass to do RPO deduction and propagation of function attributes.
Definition:
FunctionAttrs.h:70
llvm::MAK_MayWrite
Definition:
FunctionAttrs.h:35
llvm::PassInfoMixin
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition:
PassManager.h:366
llvm::LazyCallGraph
A lazily constructed view of the call graph of a module.
Definition:
LazyCallGraph.h:112
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition:
PassManager.h:154
llvm::AAResults
Definition:
AliasAnalysis.h:289
llvm::createPostOrderFunctionAttrsLegacyPass
Pass * createPostOrderFunctionAttrsLegacyPass()
Create a legacy pass manager instance of a pass to compute function attrs in post-order.
Definition:
FunctionAttrs.cpp:1429
Pass
print lazy value Lazy Value Info Printer Pass
Definition:
LazyValueInfo.cpp:1922
llvm::PostOrderFunctionAttrsPass::run
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &CG, CGSCCUpdateResult &UR)
Definition:
FunctionAttrs.cpp:1350
llvm::MAK_ReadOnly
Definition:
FunctionAttrs.h:34
llvm::MAK_WriteOnly
Definition:
FunctionAttrs.h:36
CGSCCPassManager.h
This header provides classes for managing passes over SCCs of the call graph.
llvm::MAK_ReadNone
Definition:
FunctionAttrs.h:33
llvm::LazyCallGraph::SCC
An SCC of the call graph.
Definition:
LazyCallGraph.h:431
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition:
InstructionSimplify.h:41
PassManager.h
This header defines various interfaces for pass management in LLVM.
Generated on Sun Dec 20 2020 13:53:39 for LLVM by
1.8.13