LLVM 20.0.0git
Go to the documentation of this file.
1//===- FunctionAttrs.h - Compute function attributes ------------*- C++ -*-===//
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
9/// \file
10/// Provides passes for computing function attributes based on interprocedural
11/// analyses.
21#include "llvm/IR/PassManager.h"
23namespace llvm {
25class GlobalValueSummary;
26class ModuleSummaryIndex;
27class Function;
28class Module;
30/// Returns the memory access properties of this copy of the function.
31MemoryEffects computeFunctionBodyMemoryAccess(Function &F, AAResults &AAR);
33/// Propagate function attributes for function summaries along the index's
34/// callgraph during thinlink
36 ModuleSummaryIndex &Index,
37 function_ref<bool(GlobalValue::GUID, const GlobalValueSummary *)>
38 isPrevailing);
40/// Computes function attributes in post-order over the call graph.
42/// By operating in post-order, this pass computes precise attributes for
43/// called functions prior to processsing their callers. This "bottom-up"
44/// approach allows powerful interprocedural inference of function attributes
45/// like memory access patterns, etc. It can discover functions that do not
46/// access memory, or only read memory, and give them the readnone/readonly
47/// attribute. It also discovers function arguments that are not captured by
48/// the function and marks them with the nocapture attribute.
49struct PostOrderFunctionAttrsPass : PassInfoMixin<PostOrderFunctionAttrsPass> {
50 PostOrderFunctionAttrsPass(bool SkipNonRecursive = false)
51 : SkipNonRecursive(SkipNonRecursive) {}
56 function_ref<StringRef(StringRef)> MapClassName2PassName);
59 bool SkipNonRecursive;
62/// A pass to do RPO deduction and propagation of function attributes.
64/// This pass provides a general RPO or "top down" propagation of
65/// function attributes. For a few (rare) cases, we can deduce significantly
66/// more about function attributes by working in RPO, so this pass
67/// provides the complement to the post-order pass above where the majority of
68/// deduction is performed.
69// FIXME: Currently there is no RPO CGSCC pass structure to slide into and so
70// this is a boring module pass, but eventually it should be an RPO CGSCC pass
71// when such infrastructure is available.
73 : public PassInfoMixin<ReversePostOrderFunctionAttrsPass> {
78} // end namespace llvm
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.
#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:253
uint64_t GUID
Declare a type to represent a global unique identifier for a global value.
Definition: GlobalValue.h:587
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: Analysis.h:111
A pass to do RPO deduction and propagation of function attributes.
Definition: FunctionAttrs.h:73
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.
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
Definition: ModRef.h:268
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:69
Computes function attributes in post-order over the call graph.
Definition: FunctionAttrs.h:49
PostOrderFunctionAttrsPass(bool SkipNonRecursive=false)
Definition: FunctionAttrs.h:50
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &CG, CGSCCUpdateResult &UR)
void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)