//===-- WebAssemblyDebugValueManager.cpp - WebAssembly DebugValue Manager -===// // // 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 /// This file implements the manager for MachineInstr DebugValues. /// //===----------------------------------------------------------------------===// #include "WebAssemblyDebugValueManager.h" #include "MCTargetDesc/WebAssemblyMCTargetDesc.h" #include "WebAssembly.h" #include "WebAssemblyMachineFunctionInfo.h" #include "llvm/CodeGen/MachineInstr.h" #include "llvm/IR/DebugInfoMetadata.h" #include "llvm/IR/Function.h" usingnamespacellvm; WebAssemblyDebugValueManager::WebAssemblyDebugValueManager(MachineInstr *Def) : … { … } // Returns true if both A and B are the same CONST_I32/I64/F32/F64 instructions. // Doesn't include CONST_V128. static bool isSameScalarConst(const MachineInstr *A, const MachineInstr *B) { … } SmallVector<MachineInstr *, 1> WebAssemblyDebugValueManager::getSinkableDebugValues( MachineInstr *Insert) const { … } // Returns true if the insertion point is the same as the current place. // Following DBG_VALUEs for 'Def' are ignored. bool WebAssemblyDebugValueManager::isInsertSamePlace( MachineInstr *Insert) const { … } // Returns true if any instruction in MBB has the same debug location as DL. // Also returns true if DL is an empty location. static bool hasSameDebugLoc(const MachineBasicBlock *MBB, DebugLoc DL) { … } // Sink 'Def', and also sink its eligible DBG_VALUEs to the place before // 'Insert'. Convert the original DBG_VALUEs into undefs. // // For DBG_VALUEs to sink properly, if 'Def' and 'Insert' are within the same // BB, 'Insert' should be below 'Def'; if they are in different BBs, 'Insert' // should be in one of 'Def's BBs successors. Def will be sunk regardless of the // location. // // This DebugValueManager's new Def and DbgValues will be updated to the newly // sinked Def + DBG_VALUEs. void WebAssemblyDebugValueManager::sink(MachineInstr *Insert) { … } // Clone 'Def', and also clone its eligible DBG_VALUEs to the place before // 'Insert'. // // For DBG_VALUEs to be cloned properly, if 'Def' and 'Insert' are within the // same BB, 'Insert' should be below 'Def'; if they are in different BBs, // 'Insert' should be in one of 'Def's BBs successors. Def will be cloned // regardless of the location. // // If NewReg is not $noreg, the newly cloned DBG_VALUEs will have the new // register as its operand. void WebAssemblyDebugValueManager::cloneSink(MachineInstr *Insert, Register NewReg, bool CloneDef) const { … } // Update the register for Def and DBG_VALUEs. void WebAssemblyDebugValueManager::updateReg(Register Reg) { … } void WebAssemblyDebugValueManager::replaceWithLocal(unsigned LocalId) { … } // Remove Def, and set its DBG_VALUEs to undef. void WebAssemblyDebugValueManager::removeDef() { … }