41 #define DEBUG_TYPE "wasm-store-results" 49 StringRef getPassName()
const override {
return "WebAssembly Store Results"; }
72 "Optimize store result values for WebAssembly",
false,
false)
75 return new WebAssemblyStoreResults();
80 unsigned FromReg,
unsigned ToReg,
99 if (&MI == Where || !MDT.
dominates(&MI, Where))
105 if (WhereVNI && WhereVNI != FromVNI)
110 if (ToVNI && ToVNI != FromVNI)
114 LLVM_DEBUG(
dbgs() <<
"Setting operand " << O <<
" in " << *Where <<
" from " 157 if (!callReturnsInput)
168 "signature, from/to mismatch");
172 bool WebAssemblyStoreResults::runOnMachineFunction(
MachineFunction &MF) {
174 dbgs() <<
"********** Store Results **********\n" 175 <<
"********** Function: " << MF.
getName() <<
'\n';
182 const auto &LibInfo = getAnalysis<TargetLibraryInfoWrapperPass>().getTLI();
184 bool Changed =
false;
189 assert(MRI.tracksLiveness() &&
"StoreResults expects liveness tracking");
191 for (
auto &MBB : MF) {
194 switch (
MI.getOpcode()) {
197 case WebAssembly::CALL_I32:
198 case WebAssembly::CALL_I64:
void push_back(const T &Elt)
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
MachineInstr * getParent()
getParent - Return the instruction that this operand belongs to.
static bool optimizeCall(MachineBasicBlock &MBB, MachineInstr &MI, const MachineRegisterInfo &MRI, MachineDominatorTree &MDT, LiveIntervals &LIS, const WebAssemblyTargetLowering &TLI, const TargetLibraryInfo &LibInfo)
const TargetRegisterClass * getRegClass(unsigned Reg) const
Return the register class of the specified virtual register.
LLVM_ATTRIBUTE_NORETURN void report_fatal_error(Error Err, bool gen_crash_diag=true)
Report a serious error, calling any installed error handler.
Compute iterated dominance frontiers using a linear time algorithm.
LiveInterval - This class represents the liveness of a register, or stack slot.
unsigned getReg() const
getReg - Returns the register number.
MachineBlockFrequencyInfo pass uses BlockFrequencyInfoImpl implementation to estimate machine basic b...
void setIsDead(bool Val=true)
VNInfo - Value Number Information.
use_nodbg_iterator use_nodbg_begin(unsigned RegNo) const
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end...
static use_nodbg_iterator use_nodbg_end()
AnalysisUsage & addRequired()
SlotIndex getDeadSlot() const
Returns the dead def kill slot for the current instruction.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
const char * getSymbolName() const
void extendToIndices(LiveRange &LR, ArrayRef< SlotIndex > Indices, ArrayRef< SlotIndex > Undefs)
Extend the live range LR to reach all points in Indices.
SlotIndex getRegSlot(bool EC=false) const
Returns the register use/def slot in the current instruction for a normal or early-clobber def...
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
VNInfo * getVNInfoAt(SlotIndex Idx) const
getVNInfoAt - Return the VNInfo that is live at Idx, or NULL.
unsigned const MachineRegisterInfo * MRI
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
bool liveAt(SlotIndex index) const
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
This file provides WebAssembly-specific target descriptions.
Represent the analysis usage information of a pass.
bool shrinkToUses(LiveInterval *li, SmallVectorImpl< MachineInstr *> *dead=nullptr)
After removing some uses of a register, shrink its live range to just the remaining uses...
FunctionPass class - This class is used to implement most global optimizations.
FunctionPass * createWebAssemblyStoreResults()
This file declares the WebAssembly-specific subclass of TargetSubtarget.
MachineOperand class - Representation of each machine instruction operand.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small...
bool dominates(const MachineDomTreeNode *A, const MachineDomTreeNode *B) const
Provides information about what library functions are available for the current target.
void setPreservesCFG()
This function should be called by the pass, iff they do not:
LiveInterval & getInterval(unsigned Reg)
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool getLibFunc(StringRef funcName, LibFunc &F) const
Searches for a particular function name.
SlotIndex getInstructionIndex(const MachineInstr &Instr) const
Returns the base index of the given instruction.
MachineRegisterInfo - Keep track of information for virtual and physical registers, including vreg register classes, use/def chains for registers, etc.
Representation of each machine instruction.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
static bool ReplaceDominatedUses(MachineBasicBlock &MBB, MachineInstr &MI, unsigned FromReg, unsigned ToReg, const MachineRegisterInfo &MRI, MachineDominatorTree &MDT, LiveIntervals &LIS)
INITIALIZE_PASS(WebAssemblyStoreResults, DEBUG_TYPE, "Optimize store result values for WebAssembly", false, false) FunctionPass *llvm
void setReg(unsigned Reg)
Change the register this operand corresponds to.
This file declares WebAssembly-specific per-machine-function information.
bool isSymbol() const
isSymbol - Tests if this is a MO_ExternalSymbol operand.
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool addRegisterKilled(unsigned IncomingReg, const TargetRegisterInfo *RegInfo, bool AddIfNotFound=false)
We have determined MI kills a register.
StringRef - Represent a constant reference to a string, i.e.
const MachineOperand & getOperand(unsigned i) const
SlotIndex - An opaque wrapper around machine indexes.
DominatorTree Class - Concrete subclass of DominatorTreeBase that is used to compute a normal dominat...
const char * getLibcallName(RTLIB::Libcall Call) const
Get the libcall routine name for the specified libcall.