LLVM 17.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://bugs.llvm.org/show_bug.cgi?id=50361.
13/// TODO Correctly handle DBG_VALUE_LISTs
14///
15//===----------------------------------------------------------------------===//
16
17#include "WebAssembly.h"
20using namespace llvm;
21
22#define DEBUG_TYPE "wasm-nullify-dbg-value-lists"
23
24namespace {
25class WebAssemblyNullifyDebugValueLists final : public MachineFunctionPass {
26 StringRef getPassName() const override {
27 return "WebAssembly Nullify DBG_VALUE_LISTs";
28 }
29
30 bool runOnMachineFunction(MachineFunction &MF) override;
31
32public:
33 static char ID; // Pass identification, replacement for typeid
34 WebAssemblyNullifyDebugValueLists() : MachineFunctionPass(ID) {}
35};
36} // end anonymous namespace
37
38char WebAssemblyNullifyDebugValueLists::ID = 0;
39INITIALIZE_PASS(WebAssemblyNullifyDebugValueLists, DEBUG_TYPE,
40 "WebAssembly Nullify DBG_VALUE_LISTs", false, false)
41
43 return new WebAssemblyNullifyDebugValueLists();
44}
45
46bool WebAssemblyNullifyDebugValueLists::runOnMachineFunction(
47 MachineFunction &MF) {
48 LLVM_DEBUG(dbgs() << "********** Nullify DBG_VALUE_LISTs **********\n"
49 "********** Function: "
50 << MF.getName() << '\n');
51 const auto &TII = *MF.getSubtarget<WebAssemblySubtarget>().getInstrInfo();
53 for (auto &MBB : MF)
54 for (auto &MI : MBB)
55 if (MI.getOpcode() == TargetOpcode::DBG_VALUE_LIST)
56 DbgValueLists.push_back(&MI);
57
58 // Our backend, including WebAssemblyDebugValueManager, currently cannot
59 // handle DBG_VALUE_LISTs correctly. So this converts DBG_VALUE_LISTs to
60 // "DBG_VALUE $noreg", which will appear as "optimized out".
61 for (auto *DVL : DbgValueLists) {
62 BuildMI(*DVL->getParent(), DVL, DVL->getDebugLoc(),
63 TII.get(TargetOpcode::DBG_VALUE), false, Register(),
64 DVL->getOperand(0).getMetadata(), DVL->getOperand(1).getMetadata());
65 DVL->eraseFromParent();
66 }
67
68 return !DbgValueLists.empty();
69}
MachineBasicBlock & MBB
#define LLVM_DEBUG(X)
Definition: Debug.h:101
const HexagonInstrInfo * TII
IRTranslator LLVM IR MI
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition: PassSupport.h:38
This file declares the WebAssembly-specific subclass of TargetSubtarget.
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:308
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...
const TargetSubtargetInfo & getSubtarget() const
getSubtarget - Return the subtarget for which this machine code is being compiled.
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
Wrapper class representing virtual and physical registers.
Definition: Register.h:19
void push_back(const T &Elt)
Definition: SmallVector.h:416
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Definition: SmallVector.h:1200
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
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
MachineInstrBuilder BuildMI(MachineFunction &MF, const MIMetadata &MIMD, const MCInstrDesc &MCID)
Builder interface. Specify how to create the initial instruction itself.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition: Debug.cpp:163
FunctionPass * createWebAssemblyNullifyDebugValueLists()