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";
51 WebAssemblyOptimizeReturnedLegacy() :
FunctionPass(ID) {}
57char WebAssemblyOptimizeReturnedLegacy::ID = 0;
59 "Optimize calls with \"returned\" attributes for WebAssembly",
63 return new WebAssemblyOptimizeReturnedLegacy();
66void WebAssemblyOptimizeReturnedImpl::visitCallBase(
CallBase &CB) {
76 return !
I->isLifetimeStartOrEnd() && DT->
dominates(&CB, U);
81bool WebAssemblyOptimizeReturnedImpl::runOnFunction(Function &
F) {
82 LLVM_DEBUG(
dbgs() <<
"********** Optimize returned Attributes **********\n"
83 "********** Function: "
84 <<
F.getName() <<
'\n');
90bool WebAssemblyOptimizeReturnedLegacy::runOnFunction(Function &
F) {
91 DominatorTree *DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
92 WebAssemblyOptimizeReturnedImpl Impl(DT);
93 return Impl.runOnFunction(
F);
100 WebAssemblyOptimizeReturnedImpl Impl(DT);
101 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()
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.
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.