//===-- WebAssemblyDebugFixup.cpp - Debug Fixup ------------------===// // // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. // See https://llvm.org/LICENSE.txt for license information. // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception // //===----------------------------------------------------------------------===// /// /// \file /// Several prior passes may "stackify" registers, here we ensure any references /// in such registers in debug_value instructions become stack relative also. /// This is done in a separate pass such that not all previous passes need to /// track stack depth when values get stackified. /// //===----------------------------------------------------------------------===// #include "MCTargetDesc/WebAssemblyMCTargetDesc.h" #include "WebAssembly.h" #include "WebAssemblyMachineFunctionInfo.h" #include "WebAssemblySubtarget.h" #include "WebAssemblyUtilities.h" #include "llvm/ADT/SCCIterator.h" #include "llvm/CodeGen/MachineFrameInfo.h" #include "llvm/CodeGen/MachineFunction.h" #include "llvm/CodeGen/MachineInstrBuilder.h" #include "llvm/CodeGen/MachineLoopInfo.h" #include "llvm/CodeGen/MachineRegisterInfo.h" #include "llvm/CodeGen/Passes.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" usingnamespacellvm; #define DEBUG_TYPE … namespace { class WebAssemblyDebugFixup final : public MachineFunctionPass { … }; } // end anonymous namespace char WebAssemblyDebugFixup::ID = …; INITIALIZE_PASS(…) FunctionPass *llvm::createWebAssemblyDebugFixup() { … } // At this very end of the compilation pipeline, if any DBG_VALUEs with // registers remain, it means they are dangling info which we failed to update // when their corresponding def instruction was transformed/moved/splitted etc. // Because Wasm cannot access values in LLVM virtual registers in the debugger, // these dangling DBG_VALUEs in effect kill the effect of any previous DBG_VALUE // associated with the variable, which will appear as "optimized out". static void setDanglingDebugValuesUndef(MachineBasicBlock &MBB, const TargetInstrInfo *TII) { … } bool WebAssemblyDebugFixup::runOnMachineFunction(MachineFunction &MF) { … }