LLVM  12.0.0git
ArgumentPromotion.h
Go to the documentation of this file.
1 //===- ArgumentPromotion.h - Promote by-reference arguments -----*- 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 #ifndef LLVM_TRANSFORMS_IPO_ARGUMENTPROMOTION_H
10 #define LLVM_TRANSFORMS_IPO_ARGUMENTPROMOTION_H
11 
14 #include "llvm/IR/PassManager.h"
15 
16 namespace llvm {
17 class TargetTransformInfo;
18 
19 /// Argument promotion pass.
20 ///
21 /// This pass walks the functions in each SCC and for each one tries to
22 /// transform it and all of its callers to replace indirect arguments with
23 /// direct (by-value) arguments.
24 class ArgumentPromotionPass : public PassInfoMixin<ArgumentPromotionPass> {
25  unsigned MaxElements;
26 
27 public:
28  ArgumentPromotionPass(unsigned MaxElements = 3u) : MaxElements(MaxElements) {}
29 
30  /// Check if callers and the callee \p F agree how promoted arguments would be
31  /// passed. The ones that they do not agree on are eliminated from the sets but
32  /// the return value has to be observed as well.
33  static bool areFunctionArgsABICompatible(
34  const Function &F, const TargetTransformInfo &TTI,
35  SmallPtrSetImpl<Argument *> &ArgsToPromote,
36  SmallPtrSetImpl<Argument *> &ByValArgsToTransform);
37 
38  /// Checks if a type could have padding bytes.
39  static bool isDenselyPacked(Type *type, const DataLayout &DL);
40 
43 };
44 
45 } // end namespace llvm
46 
47 #endif // LLVM_TRANSFORMS_IPO_ARGUMENTPROMOTION_H
uint64_t CallInst * C
A parsed version of the target data layout string in and methods for querying it. ...
Definition: DataLayout.h:111
This class represents lattice values for constants.
Definition: AllocatorList.h:23
Implements a lazy call graph analysis and related passes for the new pass manager.
F(f)
Support structure for SCC passes to communicate updates the call graph back to the CGSCC pass manager...
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:343
static bool areFunctionArgsABICompatible(const Function &F, const TargetTransformInfo &TTI, SmallPtrSetImpl< Argument *> &ArgsToPromote, SmallPtrSetImpl< Argument *> &ByValArgsToTransform)
Check if callers and the callee F agree how promoted arguments would be passed.
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:373
A lazily constructed view of the call graph of a module.
Argument promotion pass.
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:154
The instances of the Type class are immutable: once they are created, they are never changed...
Definition: Type.h:46
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
static bool isDenselyPacked(Type *type, const DataLayout &DL)
Checks if a type could have padding bytes.
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &CG, CGSCCUpdateResult &UR)
This header provides classes for managing passes over SCCs of the call graph.
An SCC of the call graph.
A container for analyses that lazily runs them and caches their results.
This header defines various interfaces for pass management in LLVM.
ArgumentPromotionPass(unsigned MaxElements=3u)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL