LLVM 17.0.0git
WebAssemblyDebugValueManager.cpp
Go to the documentation of this file.
1//===-- WebAssemblyDebugValueManager.cpp - WebAssembly DebugValue Manager -===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8///
9/// \file
10/// This file implements the manager for MachineInstr DebugValues.
11///
12//===----------------------------------------------------------------------===//
13
15#include "WebAssembly.h"
18
19using namespace llvm;
20
22 MachineInstr *Instr) {
23 // This code differs from MachineInstr::collectDebugValues in that it scans
24 // the whole BB, not just contiguous DBG_VALUEs.
25 if (!Instr->getOperand(0).isReg())
26 return;
27 CurrentReg = Instr->getOperand(0).getReg();
28
30 ++DI;
31 for (MachineBasicBlock::iterator DE = Instr->getParent()->end(); DI != DE;
32 ++DI) {
33 if (DI->isDebugValue() &&
34 DI->hasDebugOperandForReg(Instr->getOperand(0).getReg()))
35 DbgValues.push_back(&*DI);
36 }
37}
38
40 MachineBasicBlock *MBB = Insert->getParent();
41 for (MachineInstr *DBI : reverse(DbgValues))
42 MBB->splice(Insert, DBI->getParent(), DBI);
43}
44
46 for (auto *DBI : DbgValues)
47 for (auto &MO : DBI->getDebugOperandsForReg(CurrentReg))
48 MO.setReg(Reg);
49 CurrentReg = Reg;
50}
51
53 unsigned NewReg) {
54 MachineBasicBlock *MBB = Insert->getParent();
56 for (MachineInstr *DBI : reverse(DbgValues)) {
57 MachineInstr *Clone = MF->CloneMachineInstr(DBI);
58 for (auto &MO : Clone->getDebugOperandsForReg(CurrentReg))
59 MO.setReg(NewReg);
60 MBB->insert(Insert, Clone);
61 }
62}
63
65 for (auto *DBI : DbgValues) {
66 auto IndexType = DBI->isIndirectDebugValue()
69 for (auto &MO : DBI->getDebugOperandsForReg(CurrentReg))
70 MO.ChangeToTargetIndex(IndexType, LocalId);
71 }
72}
MachineBasicBlock & MBB
This file contains the declaration of the WebAssembly-specific manager for DebugValues associated wit...
This file declares WebAssembly-specific per-machine-function information.
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end.
instr_iterator insert(instr_iterator I, MachineInstr *M)
Insert MI into the instruction list before I, possibly inside a bundle.
const MachineFunction * getParent() const
Return the MachineFunction containing this basic block.
void splice(iterator Where, MachineBasicBlock *Other, iterator From)
Take an instruction from MBB 'Other' at the position From, and insert it into this MBB right before '...
MachineInstr * CloneMachineInstr(const MachineInstr *Orig)
Create a new MachineInstr which is a copy of Orig, identical in all ways except the instruction has n...
Representation of each machine instruction.
Definition: MachineInstr.h:68
static iterator_range< filter_iterator< Operand *, std::function< bool(Operand &Op)> > > getDebugOperandsForReg(Instruction *MI, Register Reg)
Returns a range of all of the operands that correspond to a debug use of Reg.
Definition: MachineInstr.h:566
const MachineBasicBlock * getParent() const
Definition: MachineInstr.h:313
const MachineOperand & getOperand(unsigned i) const
Definition: MachineInstr.h:526
bool isReg() const
isReg - Tests if this is a MO_Register operand.
Register getReg() const
getReg - Returns the register number.
void clone(MachineInstr *Insert, unsigned NewReg)
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
auto reverse(ContainerTy &&C)
Definition: STLExtras.h:484