LLVM 22.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"
23
24namespace llvm {
25
26class GlobalValueSummary;
27class ModuleSummaryIndex;
28class Function;
29class Module;
30
31/// Returns the memory access properties of this copy of the function.
33 AAResults &AAR);
34
35/// Propagate function attributes for function summaries along the index's
36/// callgraph during thinlink
38 ModuleSummaryIndex &Index,
39 function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
40 isPrevailing);
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.
51struct PostOrderFunctionAttrsPass : PassInfoMixin<PostOrderFunctionAttrsPass> {
52 PostOrderFunctionAttrsPass(bool SkipNonRecursive = false)
53 : SkipNonRecursive(SkipNonRecursive) {}
57
58 LLVM_ABI void
60 function_ref<StringRef(StringRef)> MapClassName2PassName);
61
62private:
63 bool SkipNonRecursive;
64};
65
66/// A pass to do RPO deduction and propagation of function attributes.
67///
68/// This pass provides a general RPO or "top down" propagation of
69/// function attributes. For a few (rare) cases, we can deduce significantly
70/// more about function attributes by working in RPO, so this pass
71/// provides the complement to the post-order pass above where the majority of
72/// deduction is performed.
73// FIXME: Currently there is no RPO CGSCC pass structure to slide into and so
74// this is a boring module pass, but eventually it should be an RPO CGSCC pass
75// when such infrastructure is available.
77 : public PassInfoMixin<ReversePostOrderFunctionAttrsPass> {
78public:
80};
81
82} // end namespace llvm
83
84#endif // LLVM_TRANSFORMS_IPO_FUNCTIONATTRS_H
This header provides classes for managing passes over SCCs of the call graph.
#define LLVM_ABI
Definition: Compiler.h:213
uint32_t Index
This header defines various interfaces for pass management in LLVM.
Implements a lazy call graph analysis and related passes for the new pass manager.
#define F(x, y, z)
Definition: MD5.cpp:55
Machine Check Debug Module
raw_pwrite_stream & OS
A container for analyses that lazily runs them and caches their results.
Definition: PassManager.h:255
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
Definition: GlobalValue.h:577
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:67
A set of analyses that are preserved following a run of a transformation pass.
Definition: Analysis.h:112
A pass to do RPO deduction and propagation of function attributes.
Definition: FunctionAttrs.h:77
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:55
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:53
@ 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
LLVM_ABI MemoryEffects computeFunctionBodyMemoryAccess(Function &F, AAResults &AAR)
Returns the memory access properties of this copy of the function.
LLVM_ABI 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.
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
Definition: ModRef.h:296
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:70
Computes function attributes in post-order over the call graph.
Definition: FunctionAttrs.h:51
PostOrderFunctionAttrsPass(bool SkipNonRecursive=false)
Definition: FunctionAttrs.h:52
LLVM_ABI PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &CG, CGSCCUpdateResult &UR)
LLVM_ABI void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)