LLVM 20.0.0git
WebAssemblyNullifyDebugValueLists.cpp
Go to the documentation of this file.
1//=== WebAssemblyNullifyDebugValueLists.cpp - Nullify DBG_VALUE_LISTs ---===//
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/// 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
14///
15//===----------------------------------------------------------------------===//
16
17#include "WebAssembly.h"
19using namespace llvm;
20
21#define DEBUG_TYPE "wasm-nullify-dbg-value-lists"
22
23namespace {
24class WebAssemblyNullifyDebugValueLists final : public MachineFunctionPass {
25 StringRef getPassName() const override {
26 return "WebAssembly Nullify DBG_VALUE_LISTs";
27 }
28
29 bool runOnMachineFunction(MachineFunction &MF) override;
30
31public:
32 static char ID; // Pass identification, replacement for typeid
33 WebAssemblyNullifyDebugValueLists() : MachineFunctionPass(ID) {}
34};
35} // end anonymous namespace
36
37char WebAssemblyNullifyDebugValueLists::ID = 0;
38INITIALIZE_PASS(WebAssemblyNullifyDebugValueLists, DEBUG_TYPE,
39 "WebAssembly Nullify DBG_VALUE_LISTs", false, false)
40
42 return new WebAssemblyNullifyDebugValueLists();
43}
44
45bool WebAssemblyNullifyDebugValueLists::runOnMachineFunction(
46 MachineFunction &MF) {
47 LLVM_DEBUG(dbgs() << "********** Nullify DBG_VALUE_LISTs **********\n"
48 "********** Function: "
49 << MF.getName() << '\n');
50 bool Changed = false;
51 // Our backend, including WebAssemblyDebugValueManager, currently cannot
52 // handle DBG_VALUE_LISTs correctly. So this makes them undefined, which will
53 // appear as "optimized out".
54 for (auto &MBB : MF) {
55 for (auto &MI : MBB) {
56 if (MI.getOpcode() == TargetOpcode::DBG_VALUE_LIST) {
57 MI.setDebugValueUndef();
58 Changed = true;
59 }
60 }
61 }
62 return Changed;
63}
MachineBasicBlock & MBB
#define LLVM_DEBUG(...)
Definition: Debug.h:106
IRTranslator LLVM IR MI
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:38
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end.
FunctionPass class - This class is used to implement most global optimizations.
Definition: Pass.h:310
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
virtual bool runOnMachineFunction(MachineFunction &MF)=0
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
virtual StringRef getPassName() const
getPassName - Return a nice clean name for a pass.
Definition: Pass.cpp:81
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:51
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Definition: CallingConv.h:24
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
FunctionPass * createWebAssemblyNullifyDebugValueLists()