LLVM 17.0.0git
FunctionAttrs.h
Go to the documentation of this file.
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.
12//
13//===----------------------------------------------------------------------===//
14
15#ifndef LLVM_TRANSFORMS_IPO_FUNCTIONATTRS_H
16#define LLVM_TRANSFORMS_IPO_FUNCTIONATTRS_H
17
21#include "llvm/IR/PassManager.h"
22
23namespace llvm {
24
25class GlobalValueSummary;
26class ModuleSummaryIndex;
27class Function;
28class Module;
29class Pass;
30
31/// Returns the memory access properties of this copy of the function.
32MemoryEffects computeFunctionBodyMemoryAccess(Function &F, AAResults &AAR);
33
34/// Propagate function attributes for function summaries along the index's
35/// callgraph during thinlink
37 ModuleSummaryIndex &Index,
38 function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
39 isPrevailing);
40
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.
50struct PostOrderFunctionAttrsPass : PassInfoMixin<PostOrderFunctionAttrsPass> {
51 PostOrderFunctionAttrsPass(bool SkipNonRecursive = false)
52 : SkipNonRecursive(SkipNonRecursive) {}
55
57 function_ref<StringRef(StringRef)> MapClassName2PassName);
58
59private:
60 bool SkipNonRecursive;
61};
62
63/// A pass to do RPO deduction and propagation of function attributes.
64///
65/// This pass provides a general RPO or "top down" propagation of
66/// function attributes. For a few (rare) cases, we can deduce significantly
67/// more about function attributes by working in RPO, so this pass
68/// provides the complement to the post-order pass above where the majority of
69/// deduction is performed.
70// FIXME: Currently there is no RPO CGSCC pass structure to slide into and so
71// this is a boring module pass, but eventually it should be an RPO CGSCC pass
72// when such infrastructure is available.
74 : public PassInfoMixin<ReversePostOrderFunctionAttrsPass> {
75public:
77};
78
79} // end namespace llvm
80
81#endif // LLVM_TRANSFORMS_IPO_FUNCTIONATTRS_H
This header provides classes for managing passes over SCCs of the call graph.
Implements a lazy call graph analysis and related passes for the new pass manager.
print lazy value Lazy Value Info Printer Pass
#define F(x, y, z)
Definition: MD5.cpp:55
Machine Check Debug Module
This header defines various interfaces for pass management in LLVM.
raw_pwrite_stream & OS
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:620
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
Definition: GlobalValue.h:583
An SCC of the call graph.
A lazily constructed view of the call graph of a module.
A Module instance is used to store all the information related to an LLVM module.
Definition: Module.h:65
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:152
A pass to do RPO deduction and propagation of function attributes.
Definition: FunctionAttrs.h:74
PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
An efficient, type-erasing, non-owning reference to a callable.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition: raw_ostream.h:52
@ C
The default llvm calling convention, compatible with C.
Definition: CallingConv.h:34
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
MemoryEffects computeFunctionBodyMemoryAccess(Function &F, AAResults &AAR)
Returns the memory access properties of this copy of the function.
bool thinLTOPropagateFunctionAttrs(ModuleSummaryIndex &Index, function_ref< bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing)
Propagate function attributes for function summaries along the index's callgraph during thinlink.
Support structure for SCC passes to communicate updates the call graph back to the CGSCC pass manager...
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:371
Computes function attributes in post-order over the call graph.
Definition: FunctionAttrs.h:50
PostOrderFunctionAttrsPass(bool SkipNonRecursive=false)
Definition: FunctionAttrs.h:51
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &CG, CGSCCUpdateResult &UR)
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)