26 if (!Def->getMF()->getFunction().getSubprogram())
32 if (!Def->getOperand(0).isReg())
34 CurrentReg = Def->getOperand(0).getReg();
40 if (MI.isDebugValue() && MI.getParent() == Def->getParent())
41 Candidates.push_back(&MI);
43 if (Candidates.empty())
49 ME = Def->getParent()->end();
52 if (MI->definesRegister(CurrentReg, nullptr))
54 if (MI->isDebugValue() && MI->hasDebugOperandForReg(CurrentReg)) {
55 DbgValues.push_back(&*MI);
56 if (DbgValues.size() == Candidates.size())
65 if (
A->getOpcode() !=
B->getOpcode() ||
70 if ((OpA.
isImm() && OpB.isImm() && OpA.
getImm() == OpB.getImm()) ||
78WebAssemblyDebugValueManager::getSinkableDebugValues(
80 if (DbgValues.empty())
83 SmallVector<MachineInstr *, 8> DbgValuesInBetween;
85 if (Def->getParent() ==
Insert->getParent()) {
88 bool DefFirst =
false;
90 ME = Def->getParent()->end();
96 if (
MI->isDebugValue())
105 if (!Def->getParent()->isSuccessor(
Insert->getParent()))
111 ME = Def->getParent()->end();
113 if (
MI->isDebugValue())
117 ME =
Insert->getIterator();
119 if (
MI->isDebugValue())
126 SmallDenseMap<DebugVariable, SmallVector<MachineInstr *, 2>>
127 SeenDbgVarToDbgValues;
128 for (
auto *DV : DbgValuesInBetween) {
130 DebugVariable Var(DV->getDebugVariable(), DV->getDebugExpression(),
131 DV->getDebugLoc()->getInlinedAt());
132 SeenDbgVarToDbgValues[Var].push_back(DV);
146 MachineRegisterInfo &MRI = Def->getParent()->getParent()->getRegInfo();
147 for (
auto *DV : DbgValues) {
148 DebugVariable Var(DV->getDebugVariable(), DV->getDebugExpression(),
149 DV->getDebugLoc()->getInlinedAt());
150 auto It = SeenDbgVarToDbgValues.
find(Var);
151 if (It == SeenDbgVarToDbgValues.
end()) {
157 auto &OverlappingDbgValues = It->second;
158 bool Sinkable =
true;
159 for (
auto *OverlappingDV : OverlappingDbgValues) {
160 MachineOperand &DbgOp = OverlappingDV->getDebugOperand(0);
161 if (!DbgOp.
isReg()) {
230 return SinkableDbgValues;
235bool WebAssemblyDebugValueManager::isInsertSamePlace(
237 if (Def->getParent() !=
Insert->getParent())
252 for (
const auto &
MI : *
MBB)
253 if (
MI.getDebugLoc() ==
DL)
283 if (isInsertSamePlace(Insert))
292 getSinkableDebugValues(Insert);
301 MBB->splice(Insert, Def->getParent(), Def);
303 if (DbgValues.empty())
310 MBB->insert(Insert, Clone);
354 DV->setDebugValueUndef();
356 DbgValues.
swap(NewDbgValues);
371 bool CloneDef)
const {
376 getSinkableDebugValues(Insert);
386 if (NewReg != CurrentReg && NewReg.
isValid())
388 MBB->insert(Insert, Clone);
391 if (DbgValues.empty())
398 MBB->insert(Insert, Clone);
402 if (NewReg != CurrentReg && NewReg.
isValid())
403 for (
auto *DBI : NewDbgValues)
404 for (
auto &MO : DBI->getDebugOperandsForReg(CurrentReg))
410 if (Reg != CurrentReg && Reg.isValid()) {
411 for (
auto *DBI : DbgValues)
412 for (
auto &MO : DBI->getDebugOperandsForReg(CurrentReg))
415 Def->getOperand(0).setReg(Reg);
420 for (
auto *DBI : DbgValues) {
421 auto IndexType = DBI->isIndirectDebugValue()
424 for (
auto &MO : DBI->getDebugOperandsForReg(CurrentReg))
425 MO.ChangeToTargetIndex(IndexType, LocalId);
431 Def->removeFromParent();
433 DV->setDebugValueUndef();
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
Promote Memory to Register
static bool isSameScalarConst(const MachineInstr *A, const MachineInstr *B)
static bool hasSameDebugLoc(const MachineBasicBlock *MBB, DebugLoc DL)
This file contains the declaration of the WebAssembly-specific manager for DebugValues associated wit...
This file provides WebAssembly-specific target descriptions.
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.
iterator find(const_arg_type_t< KeyT > Val)
MachineInstrBundleIterator< MachineInstr > iterator
MachineRegisterInfo & getRegInfo()
getRegInfo - Return information about the registers currently in use.
Representation of each machine instruction.
const MachineOperand & getOperand(unsigned i) const
void setDebugLoc(DebugLoc DL)
Replace current source information with new such.
MachineOperand class - Representation of each machine instruction operand.
const GlobalValue * getGlobal() const
bool isReg() const
isReg - Tests if this is a MO_Register operand.
LLVM_ABI void setReg(Register Reg)
Change the register this operand corresponds to.
bool isImm() const
isImm - Tests if this is a MO_Immediate operand.
bool isGlobal() const
isGlobal - Tests if this is a MO_GlobalAddress operand.
Register getReg() const
getReg - Returns the register number.
const ConstantFP * getFPImm() const
bool isFPImm() const
isFPImm - Tests if this is a MO_FPImmediate operand.
MachineRegisterInfo - Keep track of information for virtual and physical registers,...
const MachineFunction & getMF() const
LLVM_ABI MachineInstr * getUniqueVRegDef(Register Reg) const
getUniqueVRegDef - Return the unique machine instr that defines the specified virtual register or nul...
Wrapper class representing virtual and physical registers.
constexpr bool isValid() const
void swap(SmallVectorImpl &RHS)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
WebAssemblyDebugValueManager(MachineInstr *Def)
void updateReg(Register Reg)
void cloneSink(MachineInstr *Insert, Register NewReg=Register(), bool CloneDef=true) const
void replaceWithLocal(unsigned LocalId)
void sink(MachineInstr *Insert)
bool isScalarConst(unsigned Opc)
This is an optimization pass for GlobalISel generic memory operations.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool is_contained(R &&Range, const E &Element)
Returns true if Element is found in Range.