1 //===-- WebAssemblyDebugValueManager.cpp - WebAssembly DebugValue Manager -===//
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
7 //===----------------------------------------------------------------------===//
10 /// This file implements the manager for MachineInstr DebugValues.
12 //===----------------------------------------------------------------------===//
14 #include "WebAssemblyDebugValueManager.h"
15 #include "WebAssemblyMachineFunctionInfo.h"
16 #include "llvm/CodeGen/MachineInstr.h"
20 WebAssemblyDebugValueManager::WebAssemblyDebugValueManager(
21 MachineInstr
*Instr
) {
22 Instr
->collectDebugValues(DbgValues
);
25 void WebAssemblyDebugValueManager::move(MachineInstr
*Insert
) {
26 MachineBasicBlock
*MBB
= Insert
->getParent();
27 for (MachineInstr
*DBI
: reverse(DbgValues
))
28 MBB
->splice(Insert
, DBI
->getParent(), DBI
);
31 void WebAssemblyDebugValueManager::updateReg(unsigned Reg
) {
32 for (auto *DBI
: DbgValues
)
33 DBI
->getOperand(0).setReg(Reg
);
36 void WebAssemblyDebugValueManager::clone(MachineInstr
*Insert
,
38 MachineBasicBlock
*MBB
= Insert
->getParent();
39 MachineFunction
*MF
= MBB
->getParent();
40 for (MachineInstr
*DBI
: reverse(DbgValues
)) {
41 MachineInstr
*Clone
= MF
->CloneMachineInstr(DBI
);
42 Clone
->getOperand(0).setReg(NewReg
);
43 MBB
->insert(Insert
, Clone
);