57#define DEBUG_TYPE "inline-asm-prepare"
73char InlineAsmPrepare::ID = 0;
78 "Prepare inline asm insts",
false,
false)
84 return new InlineAsmPrepare();
93 <<
", is " << (DT.
dominates(BB, U) ?
"" :
"NOT ")
94 <<
"dominated by " << BB->
getName() <<
" ("
95 << (IsDefaultDest ?
"in" :
"") <<
"direct)\n");
102 return I &&
I->getParent() == BB;
113 if (!Visited.
insert(U).second)
123 if (
II->getIntrinsicID() == Intrinsic::callbr_landingpad)
145 Options.setMergeIdenticalEdges();
187 if (!Visited.
insert(IndDest).second)
190 Builder.SetInsertPoint(&*IndDest->begin());
192 CBR->
getType(), Intrinsic::callbr_landingpad, {CBR});
214 if (!CBR->getType()->isVoidTy() && !CBR->use_empty())
229bool InlineAsmPrepare::runOnFunction(
Function &
F) {
242 std::optional<DominatorTree> LazilyComputedDomTree;
243 if (
auto *DTWP = getAnalysisIfAvailable<DominatorTreeWrapperPass>())
244 DT = &DTWP->getDomTree();
246 LazilyComputedDomTree.emplace(
F);
247 DT = &*LazilyComputedDomTree;
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static bool runOnFunction(Function &F, bool PostInlining)
static bool runImpl(Function &F, const TargetLowering &TLI, const LibcallLoweringInfo &Libcalls, AssumptionCache *AC)
static void printDebugDomInfo(const DominatorTree &DT, const Use &U, const BasicBlock *BB, bool IsDefaultDest)
static bool runImpl(Function &F, ArrayRef< CallBrInst * > CBRs, DominatorTree *DT)
static SmallVector< CallBrInst *, 2 > findCallBrs(Function &F)
static bool processCallBrInst(Function &F, CallBrInst *CBR, DominatorTree *DT)
static bool isInSameBasicBlock(const Use &U, const BasicBlock *BB)
The Use is in the same BasicBlock as the intrinsic call.
static bool splitCriticalEdges(CallBrInst *CBR, DominatorTree *DT)
static bool insertIntrinsicCalls(CallBrInst *CBR, DominatorTree &DT)
Create a separate SSA definition in each indirect target (via llvm.callbr.landingpad).
static void updateSSA(DominatorTree &DT, CallBrInst *CBR, CallInst *Intrinsic, SSAUpdater &SSAUpdate)
uint64_t IntrinsicInst * II
FunctionAnalysisManager FAM
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
Remove Loads Into Fake Uses
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
Represent the analysis usage information of a pass.
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
LLVM Basic Block Representation.
CallBr instruction, tracking function calls that may not return control but instead transfer it to a ...
SmallVector< BasicBlock *, 16 > getIndirectDests() const
BasicBlock * getSuccessor(unsigned i) const
unsigned getNumSuccessors() const
BasicBlock * getDefaultDest() const
unsigned getNumIndirectDests() const
Return the number of callbr indirect dest labels.
This class represents a function call, abstracting a target machine's calling convention.
Analysis pass which computes a DominatorTree.
Legacy analysis pass which computes a DominatorTree.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
LLVM_ABI bool dominates(const BasicBlock *BB, const Use &U) const
Return true if the (end of the) basic block BB dominates the use U.
FunctionPass class - This class is used to implement most global optimizations.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserve()
Mark an analysis as preserved.
Helper class for SSA formation on a set of values defined in multiple blocks.
void RewriteUse(Use &U)
Rewrite a use of the symbolic value.
void Initialize(Type *Ty, StringRef Name)
Reset this object to get ready for a new set of SSA updates with type 'Ty'.
void AddAvailableValue(BasicBlock *BB, Value *V)
Indicate that a rewritten value is available in the specified block with the specified value.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
A Use represents the edge between a Value definition and its users.
Type * getType() const
All values are typed, get the type of this value.
LLVMContext & getContext() const
All values hold a context through their type.
iterator_range< use_iterator > uses()
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
const ParentTy * getParent() const
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This namespace contains an enum with a value for every intrinsic/builtin function known by LLVM.
This is an optimization pass for GlobalISel generic memory operations.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI BasicBlock * SplitKnownCriticalEdge(Instruction *TI, unsigned SuccNum, const CriticalEdgeSplittingOptions &Options=CriticalEdgeSplittingOptions(), const Twine &BBName="")
If it is known that an edge is critical, SplitKnownCriticalEdge can be called directly,...
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI bool isCriticalEdge(const Instruction *TI, unsigned SuccNum, bool AllowIdenticalEdges=false)
Return true if the specified edge is a critical edge.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
iterator_range< pointer_iterator< WrappedIteratorT > > make_pointer_range(RangeT &&Range)
LLVM_ABI FunctionPass * createInlineAsmPreparePass()
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.
Option class for critical edge splitting.