LLVM 24.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
28class Function;
29class Module;
30namespace cl {
32}
33
34/// Returns the memory access properties of this copy of the function.
36 AAResults &AAR);
37
38/// Propagate function attributes for function summaries along the index's
39/// callgraph during thinlink
41 const cl::LibraryOptionsContext &LibraryOptions, ModuleSummaryIndex &Index,
43 isPrevailing);
44
45/// Computes function attributes in post-order over the call graph.
46///
47/// By operating in post-order, this pass computes precise attributes for
48/// called functions prior to processsing their callers. This "bottom-up"
49/// approach allows powerful interprocedural inference of function attributes
50/// like memory access patterns, etc. It can discover functions that do not
51/// access memory, or only read memory, and give them the readnone/readonly
52/// attribute. It also discovers function arguments that are not captured by
53/// the function and marks them with the nocapture attribute.
55 : OptionalPassInfoMixin<PostOrderFunctionAttrsPass> {
56 PostOrderFunctionAttrsPass(bool SkipNonRecursive = false)
57 : SkipNonRecursive(SkipNonRecursive) {}
61
62 LLVM_ABI void
64 function_ref<StringRef(StringRef)> MapClassName2PassName);
65
66private:
67 bool SkipNonRecursive;
68};
69
70/// A pass to do RPO deduction and propagation of function attributes.
71///
72/// This pass provides a general RPO or "top down" propagation of
73/// function attributes. For a few (rare) cases, we can deduce significantly
74/// more about function attributes by working in RPO, so this pass
75/// provides the complement to the post-order pass above where the majority of
76/// deduction is performed.
77// FIXME: Currently there is no RPO CGSCC pass structure to slide into and so
78// this is a boring module pass, but eventually it should be an RPO CGSCC pass
79// when such infrastructure is available.
81 : public OptionalPassInfoMixin<ReversePostOrderFunctionAttrsPass> {
82public:
84};
85
86/// Additional 'norecurse' attribute deduction during postlink LTO phase.
87///
88/// This is a module pass that infers 'norecurse' attribute on functions.
89/// It runs during LTO and analyzes the module's call graph to find functions
90/// that are guaranteed not to call themselves, either directly or indirectly.
91/// The pass uses a module-wide flag which checks if any function's address is
92/// taken or any function in the module has external linkage, to safely handle
93/// indirect and library function calls from current function.
95 : public OptionalPassInfoMixin<NoRecurseLTOInferencePass> {
96public:
98};
99} // end namespace llvm
100
101#endif // LLVM_TRANSFORMS_IPO_FUNCTIONATTRS_H
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This header provides classes for managing passes over SCCs of the call graph.
#define LLVM_ABI
Definition Compiler.h:211
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:54
ModuleAnalysisManager MAM
Function and variable summary information to aid decisions and implementation of importing.
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
An SCC of the call graph.
A lazily constructed view of the call graph of a module.
Class to hold module path string table and global value map, and encapsulate methods for operating on...
A Module instance is used to store all the information related to an LLVM module.
Definition Module.h:68
Additional 'norecurse' attribute deduction during postlink LTO phase.
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &MAM)
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.
LLVM_ABI PreservedAnalyses run(Module &M, ModuleAnalysisManager &AM)
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
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
This namespace contains all of the command line option processing machinery.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI MemoryEffects computeFunctionBodyMemoryAccess(Function &F, AAResults &AAR)
Returns the memory access properties of this copy of the function.
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
Definition ModRef.h:356
AnalysisManager< LazyCallGraph::SCC, LazyCallGraph & > CGSCCAnalysisManager
The CGSCC analysis manager.
LLVM_ABI bool thinLTOPropagateFunctionAttrs(const cl::LibraryOptionsContext &LibraryOptions, ModuleSummaryIndex &Index, function_ref< bool(GlobalValue::GUID, const GlobalValueSummary *)> isPrevailing)
Propagate function attributes for function summaries along the index's callgraph during thinlink.
AnalysisManager< Module > ModuleAnalysisManager
Convenience typedef for the Module analysis manager.
Definition MIRParser.h:39
Support structure for SCC passes to communicate updates the call graph back to the CGSCC pass manager...
A CRTP mix-in for passes that can be skipped.
PostOrderFunctionAttrsPass(bool SkipNonRecursive=false)
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)