1 //=== WebAssemblyNullifyDebugValueLists.cpp - Nullify DBG_VALUE_LISTs ---===//
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 /// Nullify DBG_VALUE_LISTs instructions as a temporary measure before we
11 /// implement DBG_VALUE_LIST handling in WebAssemblyDebugValueManager.
12 /// See https://github.com/llvm/llvm-project/issues/49705.
13 /// TODO Correctly handle DBG_VALUE_LISTs
15 //===----------------------------------------------------------------------===//
17 #include "WebAssembly.h"
18 #include "WebAssemblySubtarget.h"
19 #include "llvm/CodeGen/MachineFunctionPass.h"
22 #define DEBUG_TYPE "wasm-nullify-dbg-value-lists"
25 class WebAssemblyNullifyDebugValueLists final
: public MachineFunctionPass
{
26 StringRef
getPassName() const override
{
27 return "WebAssembly Nullify DBG_VALUE_LISTs";
30 bool runOnMachineFunction(MachineFunction
&MF
) override
;
33 static char ID
; // Pass identification, replacement for typeid
34 WebAssemblyNullifyDebugValueLists() : MachineFunctionPass(ID
) {}
36 } // end anonymous namespace
38 char WebAssemblyNullifyDebugValueLists::ID
= 0;
39 INITIALIZE_PASS(WebAssemblyNullifyDebugValueLists
, DEBUG_TYPE
,
40 "WebAssembly Nullify DBG_VALUE_LISTs", false, false)
42 FunctionPass
*llvm::createWebAssemblyNullifyDebugValueLists() {
43 return new WebAssemblyNullifyDebugValueLists();
46 bool WebAssemblyNullifyDebugValueLists::runOnMachineFunction(
47 MachineFunction
&MF
) {
48 LLVM_DEBUG(dbgs() << "********** Nullify DBG_VALUE_LISTs **********\n"
49 "********** Function: "
50 << MF
.getName() << '\n');
52 // Our backend, including WebAssemblyDebugValueManager, currently cannot
53 // handle DBG_VALUE_LISTs correctly. So this makes them undefined, which will
54 // appear as "optimized out".
55 for (auto &MBB
: MF
) {
56 for (auto &MI
: MBB
) {
57 if (MI
.getOpcode() == TargetOpcode::DBG_VALUE_LIST
) {
58 MI
.setDebugValueUndef();