33#define DEBUG_TYPE "wasm-debug-fixup"
37 StringRef getPassName()
const override {
return "WebAssembly Debug Fixup"; }
52char WebAssemblyDebugFixupLegacy::ID = 0;
55 "Ensures debug_value's that have been stackified become stack relative",
59 return new WebAssemblyDebugFixupLegacy();
71 if (
MI.isDebugValue() &&
MI.getDebugOperand(0).isReg() &&
72 !
MI.isUndefDebugValue()) {
75 MI.setDebugValueUndef();
82 "********** Function: "
92 std::vector<StackElem> Stack;
95 for (
auto MII =
MBB.begin(); MII !=
MBB.end(); ++MII) {
97 if (
MI.isDebugValue()) {
98 auto &MO =
MI.getOperand(0);
100 if (MO.isReg() && MO.getReg().isValid() &&
107 for (
auto &Elem :
reverse(Stack)) {
108 if (MO.getReg() == Elem.Reg) {
109 auto Depth =
static_cast<unsigned>(&Elem - &Stack[0]);
111 <<
" -> Stack Relative " <<
Depth <<
"\n");
116 Elem.DebugValue = &
MI;
128 auto Prev = Stack.back();
130 assert(Prev.Reg == MO.getReg() &&
131 "WebAssemblyDebugFixup: Pop: Register not matched!");
134 if (Prev.DebugValue && !
MI.isTerminator()) {
139 BuildMI(*Prev.DebugValue->getParent(), std::next(MII),
140 Prev.DebugValue->getDebugLoc(),
141 TII->get(WebAssembly::DBG_VALUE),
false,
Register(),
142 Prev.DebugValue->getOperand(2).getMetadata(),
143 Prev.DebugValue->getOperand(3).getMetadata());
149 Stack.push_back({MO.getReg(),
nullptr});
155 "WebAssemblyDebugFixup: Stack not empty at end of basic block!");
163bool WebAssemblyDebugFixupLegacy::runOnMachineFunction(
MachineFunction &MF) {
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
const HexagonInstrInfo * TII
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
static void setDanglingDebugValuesUndef(MachineBasicBlock &MBB, const TargetInstrInfo *TII)
static bool debugFixup(MachineFunction &MF)
This file provides WebAssembly-specific target descriptions.
This file declares WebAssembly-specific per-machine-function information.
This file declares the WebAssembly-specific subclass of TargetSubtarget.
This file contains the declaration of the WebAssembly-specific utility functions.
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end.
Represent the analysis usage information of a 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.
FunctionPass class - This class is used to implement most global optimizations.
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - Subclasses that override getAnalysisUsage must call this.
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
Ty * getInfo()
getInfo - Keep track of various per-function pieces of information for backends that would like to do...
Representation of each machine instruction.
MachineOperand class - Representation of each machine instruction operand.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Wrapper class representing virtual and physical registers.
Represent a constant reference to a string, i.e.
TargetInstrInfo - Interface to description of machine instruction set.
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
This class is derived from MachineFunctionInfo and contains private WebAssembly-specific information ...
bool isVRegStackified(Register VReg) const
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.
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
auto reverse(ContainerTy &&C)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
FunctionPass * createWebAssemblyDebugFixupLegacyPass()
LLVM_ABI Printable printReg(Register Reg, const TargetRegisterInfo *TRI=nullptr, unsigned SubIdx=0, const MachineRegisterInfo *MRI=nullptr)
Prints virtual and physical registers with or without a TRI instance.