21#define DEBUG_TYPE "wasm-optimize-returned"
27 return "WebAssembly Optimize Returned";
49char OptimizeReturned::ID = 0;
51 "Optimize calls with \"returned\" attributes for WebAssembly",
55 return new OptimizeReturned();
58void OptimizeReturned::visitCallBase(
CallBase &CB) {
63 if (isa<Constant>(Arg))
67 [&](
Use &U) {
return DT->dominates(&CB, U); });
71bool OptimizeReturned::runOnFunction(
Function &
F) {
72 LLVM_DEBUG(
dbgs() <<
"********** Optimize returned Attributes **********\n"
73 "********** Function: "
74 <<
F.getName() <<
'\n');
76 DT = &getAnalysis<DominatorTreeWrapperPass>().getDomTree();
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
void visit(MachineFunction &MF, MachineBasicBlock &Start, std::function< void(MachineBasicBlock *)> 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.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
Base class for all callable instructions (InvokeInst and CallInst) Holds everything related to callin...
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
Legacy analysis pass which computes a DominatorTree.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
FunctionPass class - This class is used to implement most global optimizations.
virtual bool runOnFunction(Function &F)=0
runOnFunction - Virtual method overriden by subclasses to do the per-function processing of the pass.
Base class for instruction visitors.
RetTy visitCallBase(CallBase &I)
virtual void getAnalysisUsage(AnalysisUsage &) const
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
StringRef - Represent a constant reference to a string, i.e.
A Use represents the edge between a Value definition and its users.
LLVM Value Representation.
void 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...
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
This is an optimization pass for GlobalISel generic memory operations.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionPass * createWebAssemblyOptimizeReturned()