LLVM 24.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"
21#include "llvm/IR/Analysis.h"
22using namespace llvm;
23
24#define DEBUG_TYPE "wasm-nullify-dbg-value-lists"
25
26namespace {
27class WebAssemblyNullifyDebugValueListsLegacy final
28 : public MachineFunctionPass {
29 StringRef getPassName() const override {
30 return "WebAssembly Nullify DBG_VALUE_LISTs";
31 }
32
33 bool runOnMachineFunction(MachineFunction &MF) override;
34
35public:
36 static char ID; // Pass identification, replacement for typeid
37 WebAssemblyNullifyDebugValueListsLegacy() : MachineFunctionPass(ID) {}
38};
39} // end anonymous namespace
40
41char WebAssemblyNullifyDebugValueListsLegacy::ID = 0;
42INITIALIZE_PASS(WebAssemblyNullifyDebugValueListsLegacy, DEBUG_TYPE,
43 "WebAssembly Nullify DBG_VALUE_LISTs", false, false)
44
46 return new WebAssemblyNullifyDebugValueListsLegacy();
47}
48
50 LLVM_DEBUG(dbgs() << "********** Nullify DBG_VALUE_LISTs **********\n"
51 "********** Function: "
52 << MF.getName() << '\n');
53 bool Changed = false;
54 // Our backend, including WebAssemblyDebugValueManager, currently cannot
55 // handle DBG_VALUE_LISTs correctly. So this makes them undefined, which will
56 // appear as "optimized out".
57 for (auto &MBB : MF) {
58 for (auto &MI : MBB) {
59 if (MI.getOpcode() == TargetOpcode::DBG_VALUE_LIST) {
60 MI.setDebugValueUndef();
61 Changed = true;
62 }
63 }
64 }
65 return Changed;
66}
67
68bool WebAssemblyNullifyDebugValueListsLegacy::runOnMachineFunction(
69 MachineFunction &MF) {
70 return nullifyDebugValueLists(MF);
71}
72
MachineBasicBlock & MBB
#define DEBUG_TYPE
IRTranslator LLVM IR MI
#define INITIALIZE_PASS(passName, arg, name, cfg, analysis)
Definition PassSupport.h:56
#define LLVM_DEBUG(...)
Definition Debug.h:119
static bool nullifyDebugValueLists(MachineFunction &MF)
This file contains the entry points for global functions defined in the LLVM WebAssembly back-end.
Represents analyses that only rely on functions' control flow.
Definition Analysis.h:73
FunctionPass class - This class is used to implement most global optimizations.
Definition Pass.h:314
MachineFunctionPass - This class adapts the FunctionPass interface to allow convenient creation of pa...
StringRef getName() const
getName - Return the name of the corresponding LLVM function.
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
Definition Analysis.h:118
PreservedAnalyses & preserveSet()
Mark an analysis set as preserved.
Definition Analysis.h:151
Represent a constant reference to a string, i.e.
Definition StringRef.h:56
PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
Changed
Pass manager infrastructure for declaring and invalidating analyses.
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.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
LLVM_ABI PreservedAnalyses getMachineFunctionPassPreservedAnalyses()
Returns the minimum set of Analyses that all machine function passes must preserve.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
Definition Debug.cpp:209
FunctionPass * createWebAssemblyNullifyDebugValueListsLegacyPass()