LLVM  13.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
llvm::PreservedAnalyses
A set of analyses that are preserved following a run of a transformation pass.
Definition: PassManager.h:155
llvm
Definition: AllocatorList.h:23
llvm::DataLayout
A parsed version of the target data layout string in and methods for querying it.
Definition: DataLayout.h:112
llvm::ArgumentPromotionPass::areFunctionArgsABICompatible
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.
Definition: ArgumentPromotion.cpp:843
llvm::PassInfoMixin
A CRTP mix-in to automatically provide informational APIs needed for passes.
Definition: PassManager.h:374
llvm::Function
Definition: Function.h:61
llvm::TargetTransformInfo
This pass provides access to the codegen interfaces that are needed for IR-level transformations.
Definition: TargetTransformInfo.h:167
llvm::Type
The instances of the Type class are immutable: once they are created, they are never changed.
Definition: Type.h:46
F
#define F(x, y, z)
Definition: MD5.cpp:56
llvm::ArgumentPromotionPass::run
PreservedAnalyses run(LazyCallGraph::SCC &C, CGSCCAnalysisManager &AM, LazyCallGraph &CG, CGSCCUpdateResult &UR)
Definition: ArgumentPromotion.cpp:1014
llvm::LazyCallGraph::SCC
An SCC of the call graph.
Definition: LazyCallGraph.h:421
C
(vector float) vec_cmpeq(*A, *B) C
Definition: README_ALTIVEC.txt:86
LazyCallGraph.h
type
AMD64 Optimization Manual has some nice information about optimizing integer multiplication by a constant How much of it applies to Intel s X86 implementation There are definite trade offs to xmm0 cvttss2siq rdx jb L3 subss xmm0 rax cvttss2siq rdx xorq rdx rax ret instead of xmm1 cvttss2siq rcx movaps xmm2 subss xmm2 cvttss2siq rax rdx xorq rax ucomiss xmm0 cmovb rax ret Seems like the jb branch has high likelihood of being taken It would have saved a few instructions It s not possible to reference and DH registers in an instruction requiring REX prefix divb and mulb both produce results in AH If isel emits a CopyFromReg which gets turned into a movb and that can be allocated a r8b r15b To get around isel emits a CopyFromReg from AX and then right shift it down by and truncate it It s not pretty but it works We need some register allocation magic to make the hack go which would often require a callee saved register Callees usually need to keep this value live for most of their body so it doesn t add a significant burden on them We currently implement this in however this is suboptimal because it means that it would be quite awkward to implement the optimization for callers A better implementation would be to relax the LLVM IR rules for sret arguments to allow a function with an sret argument to have a non void return type
Definition: README-X86-64.txt:70
CGSCCPassManager.h
DL
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
Definition: AArch64SLSHardening.cpp:76
llvm::CGSCCUpdateResult
Support structure for SCC passes to communicate updates the call graph back to the CGSCC pass manager...
Definition: CGSCCPassManager.h:232
PassManager.h
llvm::ArgumentPromotionPass::isDenselyPacked
static bool isDenselyPacked(Type *type, const DataLayout &DL)
Checks if a type could have padding bytes.
Definition: ArgumentPromotion.cpp:771
llvm::ArgumentPromotionPass
Argument promotion pass.
Definition: ArgumentPromotion.h:24
llvm::SmallPtrSetImpl
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
Definition: SmallPtrSet.h:343
llvm::AnalysisManager
A container for analyses that lazily runs them and caches their results.
Definition: InstructionSimplify.h:44
llvm::LazyCallGraph
A lazily constructed view of the call graph of a module.
Definition: LazyCallGraph.h:112
llvm::ArgumentPromotionPass::ArgumentPromotionPass
ArgumentPromotionPass(unsigned MaxElements=3u)
Definition: ArgumentPromotion.h:28