23#define DEBUG_TYPE "wasm-optimize-returned"
26class WebAssemblyOptimizeReturnedImpl
27 :
public InstVisitor<WebAssemblyOptimizeReturnedImpl> {
31 WebAssemblyOptimizeReturnedImpl(
DominatorTree *DT) : DT(DT) {}
36class WebAssemblyOptimizeReturnedLegacy final :
public FunctionPass {
38 return "WebAssembly Optimize Returned";
58char WebAssemblyOptimizeReturnedLegacy::ID = 0;
60 "Optimize calls with \"returned\" attributes for WebAssembly",
64 return new WebAssemblyOptimizeReturnedLegacy();
67void WebAssemblyOptimizeReturnedImpl::visitCallBase(
CallBase &CB) {
77 return !
I->isLifetimeStartOrEnd() && DT->
dominates(&CB, U);
82bool WebAssemblyOptimizeReturnedImpl::runOnFunction(Function &
F) {
83 LLVM_DEBUG(
dbgs() <<
"********** Optimize returned Attributes **********\n"
84 "********** Function: "
85 <<
F.getName() <<
'\n');
91bool WebAssemblyOptimizeReturnedLegacy::runOnFunction(Function &
F) {
92 DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
93 WebAssemblyOptimizeReturnedImpl Impl(DT);
94 return Impl.runOnFunction(
F);
101 WebAssemblyOptimizeReturnedImpl Impl(DT);
102 return Impl.runOnFunction(
F)
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static bool runOnFunction(Function &F, bool PostInlining)
This header defines various interfaces for pass management in LLVM.
FunctionAnalysisManager FAM
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static void visit(BasicBlock &Start, std::function< bool(BasicBlock *)> op)
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end.
Represent the analysis usage information of a pass.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
LLVM_ABI void setPreservesCFG()
This function should be called by the pass, iff they do not:
Represents analyses that only rely on functions' control flow.
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
LLVM_ABI bool paramHasAttr(unsigned ArgNo, Attribute::AttrKind Kind) const
Determine whether the argument or parameter has the given attribute.
Value * getArgOperand(unsigned i) const
unsigned arg_size() const
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.
Base class for instruction visitors.
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Represent a constant reference to a string, i.e.
LLVM_ABI bool replaceUsesWithIf(Value *New, llvm::function_ref< bool(Use &U)> ShouldReplace)
Go through the uses list for this definition and make each use point to "V" if the callback ShouldRep...
PreservedAnalyses run(Function &F, FunctionAnalysisManager &FAM)
Pass manager infrastructure for declaring and invalidating analyses.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
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...
FunctionPass * createWebAssemblyOptimizeReturnedLegacyPass()
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.