From 588bf93c6c03b853c169e93f6f6f52248e4e464a Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Tue, 21 Jan 2020 10:59:38 -0800 Subject: [PATCH 1/5] [debugserver] Delete macOS/PPC debug server implementation macOS/PPC support was dropped in 10.6 (Snow Leopard). Differential Revision: https://reviews.llvm.org/D69524 (cherry picked from commit 9aba2ced34b295658f3f07311efe665495987426) --- .../debugserver/source/MacOSX/CMakeLists.txt | 5 - .../source/MacOSX/ppc/DNBArchImpl.cpp | 487 ------------------ .../source/MacOSX/ppc/DNBArchImpl.h | 159 ------ 3 files changed, 651 deletions(-) delete mode 100644 lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp delete mode 100644 lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h diff --git a/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt b/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt index 73ba6492a0ef5..001f861d27184 100644 --- a/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt +++ b/lldb/tools/debugserver/source/MacOSX/CMakeLists.txt @@ -26,11 +26,6 @@ if(NOT LLDB_DEBUGSERVER_ARCH OR "${LLDB_DEBUGSERVER_ARCH}" MATCHES ".*86.*") include_directories(${CURRENT_SOURCE_DIR}/i386 ${CURRENT_SOURCE_DIR}/x86_64) endif() -if("${LLDB_DEBUGSERVER_ARCH}" MATCHES ".*ppc.*") - list(APPEND SOURCES ppc/DNBArchImpl.cpp) - include_directories(${CURRENT_SOURCE_DIR}/ppc) -endif() - add_subdirectory(DarwinLog) include_directories(..) diff --git a/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp b/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp deleted file mode 100644 index c6671b5066a4b..0000000000000 --- a/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.cpp +++ /dev/null @@ -1,487 +0,0 @@ -//===-- DNBArchImpl.cpp -----------------------------------------*- C++ -*-===// -// -// 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 -// -//===----------------------------------------------------------------------===// -// -// Created by Greg Clayton on 6/25/07. -// -//===----------------------------------------------------------------------===// - -#if defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__) - -#if __DARWIN_UNIX03 -#define PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(reg) __##reg -#else -#define PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(reg) reg -#endif - -#include "MacOSX/ppc/DNBArchImpl.h" -#include "DNBBreakpoint.h" -#include "DNBLog.h" -#include "DNBRegisterInfo.h" -#include "MacOSX/MachThread.h" - -static const uint8_t g_breakpoint_opcode[] = {0x7F, 0xC0, 0x00, 0x08}; - -const uint8_t *DNBArchMachPPC::SoftwareBreakpointOpcode(nub_size_t size) { - if (size == 4) - return g_breakpoint_opcode; - return NULL; -} - -uint32_t DNBArchMachPPC::GetCPUType() { return CPU_TYPE_POWERPC; } - -uint64_t DNBArchMachPPC::GetPC(uint64_t failValue) { - // Get program counter - if (GetGPRState(false) == KERN_SUCCESS) - return m_state.gpr.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(srr0); - return failValue; -} - -kern_return_t DNBArchMachPPC::SetPC(uint64_t value) { - // Get program counter - kern_return_t err = GetGPRState(false); - if (err == KERN_SUCCESS) { - m_state.gpr.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(srr0) = value; - err = SetGPRState(); - } - return err == KERN_SUCCESS; -} - -uint64_t DNBArchMachPPC::GetSP(uint64_t failValue) { - // Get stack pointer - if (GetGPRState(false) == KERN_SUCCESS) - return m_state.gpr.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(r1); - return failValue; -} - -kern_return_t DNBArchMachPPC::GetGPRState(bool force) { - if (force || m_state.GetError(e_regSetGPR, Read)) { - mach_msg_type_number_t count = e_regSetWordSizeGPR; - m_state.SetError(e_regSetGPR, Read, - ::thread_get_state(m_thread->MachPortNumber(), e_regSetGPR, - (thread_state_t)&m_state.gpr, &count)); - } - return m_state.GetError(e_regSetGPR, Read); -} - -kern_return_t DNBArchMachPPC::GetFPRState(bool force) { - if (force || m_state.GetError(e_regSetFPR, Read)) { - mach_msg_type_number_t count = e_regSetWordSizeFPR; - m_state.SetError(e_regSetFPR, Read, - ::thread_get_state(m_thread->MachPortNumber(), e_regSetFPR, - (thread_state_t)&m_state.fpr, &count)); - } - return m_state.GetError(e_regSetFPR, Read); -} - -kern_return_t DNBArchMachPPC::GetEXCState(bool force) { - if (force || m_state.GetError(e_regSetEXC, Read)) { - mach_msg_type_number_t count = e_regSetWordSizeEXC; - m_state.SetError(e_regSetEXC, Read, - ::thread_get_state(m_thread->MachPortNumber(), e_regSetEXC, - (thread_state_t)&m_state.exc, &count)); - } - return m_state.GetError(e_regSetEXC, Read); -} - -kern_return_t DNBArchMachPPC::GetVECState(bool force) { - if (force || m_state.GetError(e_regSetVEC, Read)) { - mach_msg_type_number_t count = e_regSetWordSizeVEC; - m_state.SetError(e_regSetVEC, Read, - ::thread_get_state(m_thread->MachPortNumber(), e_regSetVEC, - (thread_state_t)&m_state.vec, &count)); - } - return m_state.GetError(e_regSetVEC, Read); -} - -kern_return_t DNBArchMachPPC::SetGPRState() { - m_state.SetError(e_regSetGPR, Write, - ::thread_set_state(m_thread->MachPortNumber(), e_regSetGPR, - (thread_state_t)&m_state.gpr, - e_regSetWordSizeGPR)); - return m_state.GetError(e_regSetGPR, Write); -} - -kern_return_t DNBArchMachPPC::SetFPRState() { - m_state.SetError(e_regSetFPR, Write, - ::thread_set_state(m_thread->MachPortNumber(), e_regSetFPR, - (thread_state_t)&m_state.fpr, - e_regSetWordSizeFPR)); - return m_state.GetError(e_regSetFPR, Write); -} - -kern_return_t DNBArchMachPPC::SetEXCState() { - m_state.SetError(e_regSetEXC, Write, - ::thread_set_state(m_thread->MachPortNumber(), e_regSetEXC, - (thread_state_t)&m_state.exc, - e_regSetWordSizeEXC)); - return m_state.GetError(e_regSetEXC, Write); -} - -kern_return_t DNBArchMachPPC::SetVECState() { - m_state.SetError(e_regSetVEC, Write, - ::thread_set_state(m_thread->MachPortNumber(), e_regSetVEC, - (thread_state_t)&m_state.vec, - e_regSetWordSizeVEC)); - return m_state.GetError(e_regSetVEC, Write); -} - -bool DNBArchMachPPC::ThreadWillResume() { - bool success = true; - - // Do we need to step this thread? If so, let the mach thread tell us so. - if (m_thread->IsStepping()) { - // This is the primary thread, let the arch do anything it needs - success = EnableHardwareSingleStep(true) == KERN_SUCCESS; - } - return success; -} - -bool DNBArchMachPPC::ThreadDidStop() { - bool success = true; - - m_state.InvalidateAllRegisterStates(); - - // Are we stepping a single instruction? - if (GetGPRState(true) == KERN_SUCCESS) { - // We are single stepping, was this the primary thread? - if (m_thread->IsStepping()) { - // This was the primary thread, we need to clear the trace - // bit if so. - success = EnableHardwareSingleStep(false) == KERN_SUCCESS; - } else { - // The MachThread will automatically restore the suspend count - // in ThreadDidStop(), so we don't need to do anything here if - // we weren't the primary thread the last time - } - } - return success; -} - -// Set the single step bit in the processor status register. -kern_return_t DNBArchMachPPC::EnableHardwareSingleStep(bool enable) { - DNBLogThreadedIf(LOG_STEP, - "DNBArchMachPPC::EnableHardwareSingleStep( enable = %d )", - enable); - if (GetGPRState(false) == KERN_SUCCESS) { - const uint32_t trace_bit = 0x400; - if (enable) - m_state.gpr.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(srr1) |= trace_bit; - else - m_state.gpr.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(srr1) &= ~trace_bit; - return SetGPRState(); - } - return m_state.GetError(e_regSetGPR, Read); -} - -// Register information definitions for 32 bit PowerPC. - -enum gpr_regnums { - e_regNumGPR_srr0, - e_regNumGPR_srr1, - e_regNumGPR_r0, - e_regNumGPR_r1, - e_regNumGPR_r2, - e_regNumGPR_r3, - e_regNumGPR_r4, - e_regNumGPR_r5, - e_regNumGPR_r6, - e_regNumGPR_r7, - e_regNumGPR_r8, - e_regNumGPR_r9, - e_regNumGPR_r10, - e_regNumGPR_r11, - e_regNumGPR_r12, - e_regNumGPR_r13, - e_regNumGPR_r14, - e_regNumGPR_r15, - e_regNumGPR_r16, - e_regNumGPR_r17, - e_regNumGPR_r18, - e_regNumGPR_r19, - e_regNumGPR_r20, - e_regNumGPR_r21, - e_regNumGPR_r22, - e_regNumGPR_r23, - e_regNumGPR_r24, - e_regNumGPR_r25, - e_regNumGPR_r26, - e_regNumGPR_r27, - e_regNumGPR_r28, - e_regNumGPR_r29, - e_regNumGPR_r30, - e_regNumGPR_r31, - e_regNumGPR_cr, - e_regNumGPR_xer, - e_regNumGPR_lr, - e_regNumGPR_ctr, - e_regNumGPR_mq, - e_regNumGPR_vrsave -}; - -// General purpose registers -static DNBRegisterInfo g_gpr_registers[] = { - {"srr0", Uint, 4, Hex}, {"srr1", Uint, 4, Hex}, {"r0", Uint, 4, Hex}, - {"r1", Uint, 4, Hex}, {"r2", Uint, 4, Hex}, {"r3", Uint, 4, Hex}, - {"r4", Uint, 4, Hex}, {"r5", Uint, 4, Hex}, {"r6", Uint, 4, Hex}, - {"r7", Uint, 4, Hex}, {"r8", Uint, 4, Hex}, {"r9", Uint, 4, Hex}, - {"r10", Uint, 4, Hex}, {"r11", Uint, 4, Hex}, {"r12", Uint, 4, Hex}, - {"r13", Uint, 4, Hex}, {"r14", Uint, 4, Hex}, {"r15", Uint, 4, Hex}, - {"r16", Uint, 4, Hex}, {"r17", Uint, 4, Hex}, {"r18", Uint, 4, Hex}, - {"r19", Uint, 4, Hex}, {"r20", Uint, 4, Hex}, {"r21", Uint, 4, Hex}, - {"r22", Uint, 4, Hex}, {"r23", Uint, 4, Hex}, {"r24", Uint, 4, Hex}, - {"r25", Uint, 4, Hex}, {"r26", Uint, 4, Hex}, {"r27", Uint, 4, Hex}, - {"r28", Uint, 4, Hex}, {"r29", Uint, 4, Hex}, {"r30", Uint, 4, Hex}, - {"r31", Uint, 4, Hex}, {"cr", Uint, 4, Hex}, {"xer", Uint, 4, Hex}, - {"lr", Uint, 4, Hex}, {"ctr", Uint, 4, Hex}, {"mq", Uint, 4, Hex}, - {"vrsave", Uint, 4, Hex}, -}; - -// Floating point registers -static DNBRegisterInfo g_fpr_registers[] = { - {"fp0", IEEE754, 8, Float}, {"fp1", IEEE754, 8, Float}, - {"fp2", IEEE754, 8, Float}, {"fp3", IEEE754, 8, Float}, - {"fp4", IEEE754, 8, Float}, {"fp5", IEEE754, 8, Float}, - {"fp6", IEEE754, 8, Float}, {"fp7", IEEE754, 8, Float}, - {"fp8", IEEE754, 8, Float}, {"fp9", IEEE754, 8, Float}, - {"fp10", IEEE754, 8, Float}, {"fp11", IEEE754, 8, Float}, - {"fp12", IEEE754, 8, Float}, {"fp13", IEEE754, 8, Float}, - {"fp14", IEEE754, 8, Float}, {"fp15", IEEE754, 8, Float}, - {"fp16", IEEE754, 8, Float}, {"fp17", IEEE754, 8, Float}, - {"fp18", IEEE754, 8, Float}, {"fp19", IEEE754, 8, Float}, - {"fp20", IEEE754, 8, Float}, {"fp21", IEEE754, 8, Float}, - {"fp22", IEEE754, 8, Float}, {"fp23", IEEE754, 8, Float}, - {"fp24", IEEE754, 8, Float}, {"fp25", IEEE754, 8, Float}, - {"fp26", IEEE754, 8, Float}, {"fp27", IEEE754, 8, Float}, - {"fp28", IEEE754, 8, Float}, {"fp29", IEEE754, 8, Float}, - {"fp30", IEEE754, 8, Float}, {"fp31", IEEE754, 8, Float}, - {"fpscr", Uint, 4, Hex}}; - -// Exception registers - -static DNBRegisterInfo g_exc_registers[] = {{"dar", Uint, 4, Hex}, - {"dsisr", Uint, 4, Hex}, - {"exception", Uint, 4, Hex}}; - -// Altivec registers -static DNBRegisterInfo g_vec_registers[] = { - {"vr0", Vector, 16, VectorOfFloat32}, - {"vr1", Vector, 16, VectorOfFloat32}, - {"vr2", Vector, 16, VectorOfFloat32}, - {"vr3", Vector, 16, VectorOfFloat32}, - {"vr4", Vector, 16, VectorOfFloat32}, - {"vr5", Vector, 16, VectorOfFloat32}, - {"vr6", Vector, 16, VectorOfFloat32}, - {"vr7", Vector, 16, VectorOfFloat32}, - {"vr8", Vector, 16, VectorOfFloat32}, - {"vr9", Vector, 16, VectorOfFloat32}, - {"vr10", Vector, 16, VectorOfFloat32}, - {"vr11", Vector, 16, VectorOfFloat32}, - {"vr12", Vector, 16, VectorOfFloat32}, - {"vr13", Vector, 16, VectorOfFloat32}, - {"vr14", Vector, 16, VectorOfFloat32}, - {"vr15", Vector, 16, VectorOfFloat32}, - {"vr16", Vector, 16, VectorOfFloat32}, - {"vr17", Vector, 16, VectorOfFloat32}, - {"vr18", Vector, 16, VectorOfFloat32}, - {"vr19", Vector, 16, VectorOfFloat32}, - {"vr20", Vector, 16, VectorOfFloat32}, - {"vr21", Vector, 16, VectorOfFloat32}, - {"vr22", Vector, 16, VectorOfFloat32}, - {"vr23", Vector, 16, VectorOfFloat32}, - {"vr24", Vector, 16, VectorOfFloat32}, - {"vr25", Vector, 16, VectorOfFloat32}, - {"vr26", Vector, 16, VectorOfFloat32}, - {"vr27", Vector, 16, VectorOfFloat32}, - {"vr28", Vector, 16, VectorOfFloat32}, - {"vr29", Vector, 16, VectorOfFloat32}, - {"vr30", Vector, 16, VectorOfFloat32}, - {"vr31", Vector, 16, VectorOfFloat32}, - {"vscr", Uint, 16, Hex}, - {"vrvalid", Uint, 4, Hex}}; - -// Number of registers in each register set -const size_t k_num_gpr_registers = - sizeof(g_gpr_registers) / sizeof(DNBRegisterInfo); -const size_t k_num_fpr_registers = - sizeof(g_fpr_registers) / sizeof(DNBRegisterInfo); -const size_t k_num_exc_registers = - sizeof(g_exc_registers) / sizeof(DNBRegisterInfo); -const size_t k_num_vec_registers = - sizeof(g_vec_registers) / sizeof(DNBRegisterInfo); -// Total number of registers for this architecture -const size_t k_num_ppc_registers = k_num_gpr_registers + k_num_fpr_registers + - k_num_exc_registers + k_num_vec_registers; - -// Register set definitions. The first definitions at register set index -// of zero is for all registers, followed by other registers sets. The -// register information for the all register set need not be filled in. -static const DNBRegisterSetInfo g_reg_sets[] = { - {"PowerPC Registers", NULL, k_num_ppc_registers}, - {"General Purpose Registers", g_gpr_registers, k_num_gpr_registers}, - {"Floating Point Registers", g_fpr_registers, k_num_fpr_registers}, - {"Exception State Registers", g_exc_registers, k_num_exc_registers}, - {"Altivec Registers", g_vec_registers, k_num_vec_registers}}; -// Total number of register sets for this architecture -const size_t k_num_register_sets = - sizeof(g_reg_sets) / sizeof(DNBRegisterSetInfo); - -const DNBRegisterSetInfo * -DNBArchMachPPC::GetRegisterSetInfo(nub_size_t *num_reg_sets) const { - *num_reg_sets = k_num_register_sets; - return g_reg_sets; -} - -bool DNBArchMachPPC::GetRegisterValue(uint32_t set, uint32_t reg, - DNBRegisterValue *value) const { - if (set == REGISTER_SET_GENERIC) { - switch (reg) { - case GENERIC_REGNUM_PC: // Program Counter - set = e_regSetGPR; - reg = e_regNumGPR_srr0; - break; - - case GENERIC_REGNUM_SP: // Stack Pointer - set = e_regSetGPR; - reg = e_regNumGPR_r1; - break; - - case GENERIC_REGNUM_FP: // Frame Pointer - // Return false for now instead of returning r30 as gcc 3.x would - // use a variety of registers for the FP and it takes inspecting - // the stack to make sure there is a frame pointer before we can - // determine the FP. - return false; - - case GENERIC_REGNUM_RA: // Return Address - set = e_regSetGPR; - reg = e_regNumGPR_lr; - break; - - case GENERIC_REGNUM_FLAGS: // Processor flags register - set = e_regSetGPR; - reg = e_regNumGPR_srr1; - break; - - default: - return false; - } - } - - if (!m_state.RegsAreValid(set)) - return false; - - const DNBRegisterInfo *regInfo = m_thread->GetRegisterInfo(set, reg); - if (regInfo) { - value->info = *regInfo; - switch (set) { - case e_regSetGPR: - if (reg < k_num_gpr_registers) { - value->value.uint32 = - (&m_state.gpr.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(srr0))[reg]; - return true; - } - break; - - case e_regSetFPR: - if (reg < 32) { - value->value.float64 = - m_state.fpr.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(fpregs)[reg]; - return true; - } else if (reg == 32) { - value->value.uint32 = - m_state.fpr.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(fpscr); - return true; - } - break; - - case e_regSetEXC: - if (reg < k_num_exc_registers) { - value->value.uint32 = - (&m_state.exc.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(dar))[reg]; - return true; - } - break; - - case e_regSetVEC: - if (reg < k_num_vec_registers) { - if (reg < 33) // FP0 - FP31 and VSCR - { - // Copy all 4 uint32 values for this vector register - value->value.v_uint32[0] = - m_state.vec.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(save_vr)[reg] - [0]; - value->value.v_uint32[1] = - m_state.vec.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(save_vr)[reg] - [1]; - value->value.v_uint32[2] = - m_state.vec.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(save_vr)[reg] - [2]; - value->value.v_uint32[3] = - m_state.vec.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(save_vr)[reg] - [3]; - return true; - } else if (reg == 34) // VRVALID - { - value->value.uint32 = - m_state.vec.PREFIX_DOUBLE_UNDERSCORE_DARWIN_UNIX03(save_vrvalid); - return true; - } - } - break; - } - } - return false; -} - -kern_return_t DNBArchMachPPC::GetRegisterState(int set, bool force) { - switch (set) { - case e_regSetALL: - return GetGPRState(force) | GetFPRState(force) | GetEXCState(force) | - GetVECState(force); - case e_regSetGPR: - return GetGPRState(force); - case e_regSetFPR: - return GetFPRState(force); - case e_regSetEXC: - return GetEXCState(force); - case e_regSetVEC: - return GetVECState(force); - default: - break; - } - return KERN_INVALID_ARGUMENT; -} - -kern_return_t DNBArchMachPPC::SetRegisterState(int set) { - // Make sure we have a valid context to set. - kern_return_t err = GetRegisterState(set, false); - if (err != KERN_SUCCESS) - return err; - - switch (set) { - case e_regSetALL: - return SetGPRState() | SetFPRState() | SetEXCState() | SetVECState(); - case e_regSetGPR: - return SetGPRState(); - case e_regSetFPR: - return SetFPRState(); - case e_regSetEXC: - return SetEXCState(); - case e_regSetVEC: - return SetVECState(); - default: - break; - } - return KERN_INVALID_ARGUMENT; -} - -bool DNBArchMachPPC::RegisterSetStateIsValid(int set) const { - return m_state.RegsAreValid(set); -} - -#endif // #if defined (__powerpc__) || defined (__ppc__) || defined (__ppc64__) diff --git a/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h b/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h deleted file mode 100644 index 7d20f18d0276b..0000000000000 --- a/lldb/tools/debugserver/source/MacOSX/ppc/DNBArchImpl.h +++ /dev/null @@ -1,159 +0,0 @@ -//===-- DNBArchImpl.h -------------------------------------------*- C++ -*-===// -// -// 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 -// -//===----------------------------------------------------------------------===// -// -// Created by Greg Clayton on 6/25/07. -// -//===----------------------------------------------------------------------===// - -#ifndef __DebugNubArchMachPPC_h__ -#define __DebugNubArchMachPPC_h__ - -#if defined(__powerpc__) || defined(__ppc__) || defined(__ppc64__) - -#include "DNBArch.h" - -class MachThread; - -class DNBArchMachPPC : public DNBArchProtocol { -public: - DNBArchMachPPC(MachThread *thread) : m_thread(thread), m_state() {} - - virtual ~DNBArchMachPPC() {} - - virtual const DNBRegisterSetInfo * - GetRegisterSetInfo(nub_size_t *num_reg_sets) const; - virtual bool GetRegisterValue(uint32_t set, uint32_t reg, - DNBRegisterValue *value) const; - virtual kern_return_t GetRegisterState(int set, bool force); - virtual kern_return_t SetRegisterState(int set); - virtual bool RegisterSetStateIsValid(int set) const; - - virtual uint64_t GetPC(uint64_t failValue); // Get program counter - virtual kern_return_t SetPC(uint64_t value); - virtual uint64_t GetSP(uint64_t failValue); // Get stack pointer - virtual bool ThreadWillResume(); - virtual bool ThreadDidStop(); - - static const uint8_t *SoftwareBreakpointOpcode(nub_size_t byte_size); - static uint32_t GetCPUType(); - -protected: - kern_return_t EnableHardwareSingleStep(bool enable); - - enum RegisterSet { - e_regSetALL = REGISTER_SET_ALL, - e_regSetGPR, - e_regSetFPR, - e_regSetEXC, - e_regSetVEC, - kNumRegisterSets - }; - - typedef enum RegisterSetWordSizeTag { - e_regSetWordSizeGPR = PPC_THREAD_STATE_COUNT, - e_regSetWordSizeFPR = PPC_FLOAT_STATE_COUNT, - e_regSetWordSizeEXC = PPC_EXCEPTION_STATE_COUNT, - e_regSetWordSizeVEC = PPC_VECTOR_STATE_COUNT - } RegisterSetWordSize; - - enum { Read = 0, Write = 1, kNumErrors = 2 }; - - struct State { - ppc_thread_state_t gpr; - ppc_float_state_t fpr; - ppc_exception_state_t exc; - ppc_vector_state_t vec; - kern_return_t gpr_errs[2]; // Read/Write errors - kern_return_t fpr_errs[2]; // Read/Write errors - kern_return_t exc_errs[2]; // Read/Write errors - kern_return_t vec_errs[2]; // Read/Write errors - - State() { - uint32_t i; - for (i = 0; i < kNumErrors; i++) { - gpr_errs[i] = -1; - fpr_errs[i] = -1; - exc_errs[i] = -1; - vec_errs[i] = -1; - } - } - void InvalidateAllRegisterStates() { SetError(e_regSetALL, Read, -1); } - kern_return_t GetError(int set, uint32_t err_idx) const { - if (err_idx < kNumErrors) { - switch (set) { - // When getting all errors, just OR all values together to see if - // we got any kind of error. - case e_regSetALL: - return gpr_errs[err_idx] | fpr_errs[err_idx] | exc_errs[err_idx] | - vec_errs[err_idx]; - case e_regSetGPR: - return gpr_errs[err_idx]; - case e_regSetFPR: - return fpr_errs[err_idx]; - case e_regSetEXC: - return exc_errs[err_idx]; - case e_regSetVEC: - return vec_errs[err_idx]; - default: - break; - } - } - return -1; - } - bool SetError(int set, uint32_t err_idx, kern_return_t err) { - if (err_idx < kNumErrors) { - switch (set) { - case e_regSetALL: - gpr_errs[err_idx] = fpr_errs[err_idx] = exc_errs[err_idx] = - vec_errs[err_idx] = err; - return true; - - case e_regSetGPR: - gpr_errs[err_idx] = err; - return true; - - case e_regSetFPR: - fpr_errs[err_idx] = err; - return true; - - case e_regSetEXC: - exc_errs[err_idx] = err; - return true; - - case e_regSetVEC: - vec_errs[err_idx] = err; - return true; - - default: - break; - } - } - return false; - } - bool RegsAreValid(int set) const { - return GetError(set, Read) == KERN_SUCCESS; - } - }; - - kern_return_t GetGPRState(bool force); - kern_return_t GetFPRState(bool force); - kern_return_t GetEXCState(bool force); - kern_return_t GetVECState(bool force); - - kern_return_t SetGPRState(); - kern_return_t SetFPRState(); - kern_return_t SetEXCState(); - kern_return_t SetVECState(); - -protected: - MachThread *m_thread; - State m_state; -}; - -#endif // #if defined (__powerpc__) || defined (__ppc__) || defined (__ppc64__) -#endif // #ifndef __DebugNubArchMachPPC_h__ From 808e6c66673e6c9ae2c34b109e08264dfcaf00c5 Mon Sep 17 00:00:00 2001 From: Vedant Kumar Date: Tue, 21 Jan 2020 11:03:58 -0800 Subject: [PATCH 2/5] [debugserver] Delete stale code referencing ppc (cherry picked from commit 441aebc5235af164a784d0b9bd460c07e01e9045) --- lldb/tools/debugserver/source/DNBArch.h | 1 - lldb/tools/debugserver/source/DNBDefs.h | 6 ++---- lldb/tools/debugserver/source/RNBDefs.h | 8 -------- lldb/tools/debugserver/source/RNBServices.cpp | 5 ++--- 4 files changed, 4 insertions(+), 16 deletions(-) diff --git a/lldb/tools/debugserver/source/DNBArch.h b/lldb/tools/debugserver/source/DNBArch.h index b5e2e25ef47e6..03b6b60ed86de 100644 --- a/lldb/tools/debugserver/source/DNBArch.h +++ b/lldb/tools/debugserver/source/DNBArch.h @@ -120,7 +120,6 @@ class DNBArchProtocol { #include "MacOSX/arm/DNBArchImpl.h" #include "MacOSX/arm64/DNBArchImplARM64.h" #include "MacOSX/i386/DNBArchImplI386.h" -#include "MacOSX/ppc/DNBArchImpl.h" #include "MacOSX/x86_64/DNBArchImplX86_64.h" #endif diff --git a/lldb/tools/debugserver/source/DNBDefs.h b/lldb/tools/debugserver/source/DNBDefs.h index 22cfce1757f7f..2136eb6d5c44d 100644 --- a/lldb/tools/debugserver/source/DNBDefs.h +++ b/lldb/tools/debugserver/source/DNBDefs.h @@ -20,15 +20,13 @@ #include // Define nub_addr_t and the invalid address value from the architecture -#if defined(__x86_64__) || defined(__ppc64__) || defined(__arm64__) || \ - defined(__aarch64__) +#if defined(__x86_64__) || defined(__arm64__) || defined(__aarch64__) // 64 bit address architectures typedef uint64_t nub_addr_t; #define INVALID_NUB_ADDRESS ((nub_addr_t)~0ull) -#elif defined(__i386__) || defined(__powerpc__) || defined(__ppc__) || \ - defined(__arm__) +#elif defined(__i386__) || defined(__powerpc__) || defined(__arm__) // 32 bit address architectures diff --git a/lldb/tools/debugserver/source/RNBDefs.h b/lldb/tools/debugserver/source/RNBDefs.h index 4cc7c220b7f29..fe5d9de04cbe0 100644 --- a/lldb/tools/debugserver/source/RNBDefs.h +++ b/lldb/tools/debugserver/source/RNBDefs.h @@ -50,14 +50,6 @@ extern "C" const double CONCAT(DEBUGSERVER_PROGRAM_SYMBOL, VersionNumber); #define RNB_ARCH "x86_64" -#elif defined(__ppc64__) - -#define RNB_ARCH "ppc64" - -#elif defined(__powerpc__) || defined(__ppc__) - -#define RNB_ARCH "ppc" - #elif defined(__arm64__) || defined(__aarch64__) #define RNB_ARCH "arm64" diff --git a/lldb/tools/debugserver/source/RNBServices.cpp b/lldb/tools/debugserver/source/RNBServices.cpp index 085aaddfaf15d..7b2ab7c9b7376 100644 --- a/lldb/tools/debugserver/source/RNBServices.cpp +++ b/lldb/tools/debugserver/source/RNBServices.cpp @@ -62,9 +62,8 @@ int GetProcesses(CFMutableArrayRef plistMutableArray, bool all_users) { proc_info.kp_proc.p_stat == SZOMB || // Zombies are bad, they like brains... proc_info.kp_proc.p_flag & P_TRACED || // Being debugged? - proc_info.kp_proc.p_flag & P_WEXIT || // Working on exiting? - proc_info.kp_proc.p_flag & - P_TRANSLATED) // Skip translated ppc (Rosetta) + proc_info.kp_proc.p_flag & P_WEXIT // Working on exiting? + ) continue; // Create a new mutable dictionary for each application From 4ba4751862cbfc16ded81622dabfa1954d552c4a Mon Sep 17 00:00:00 2001 From: Tom Weaver Date: Fri, 24 Jan 2020 16:29:05 +0000 Subject: [PATCH 3/5] [DebugInfo][LiveDebugValues] Teach Live Debug Values About Meta Instructions Previously LiveDebugValues pass would consider meta instructions that 'fiddle' with liveness of registers as register definitions when transfering register defs. This would mean that, for example, a KILL instruction would cause LiveDebugValues to terminate the range of an earlier DBG_VALUE instruction resulting in the none propogation of said DBG_VALUE instructions into later blocks. This patch adds the check and a helpful comment, fixes a test that previously tested for the broken behaviour by coincidence and adds a test specifically for this. reviewers: vsk, dstenb, djtodoro Differential Revision: https://reviews.llvm.org/D73210 (cherry picked from commit f5147765ba170b4809dc72d34359be3355d48de8) --- llvm/lib/CodeGen/LiveDebugValues.cpp | 6 ++ .../MIR/X86/entry-value-of-modified-param.mir | 1 - ...vedebugvalues-ignores-metaInstructions.mir | 64 +++++++++++++++++++ 3 files changed, 70 insertions(+), 1 deletion(-) create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues-ignores-metaInstructions.mir diff --git a/llvm/lib/CodeGen/LiveDebugValues.cpp b/llvm/lib/CodeGen/LiveDebugValues.cpp index 2226c10b49a43..6acaf4099c3e7 100644 --- a/llvm/lib/CodeGen/LiveDebugValues.cpp +++ b/llvm/lib/CodeGen/LiveDebugValues.cpp @@ -922,6 +922,12 @@ void LiveDebugValues::insertTransferDebugPair( void LiveDebugValues::transferRegisterDef( MachineInstr &MI, OpenRangesSet &OpenRanges, VarLocMap &VarLocIDs, TransferMap &Transfers) { + + // Meta Instructions do not affect the debug liveness of any register they + // define. + if (MI.isMetaInstruction()) + return; + MachineFunction *MF = MI.getMF(); const TargetLowering *TLI = MF->getSubtarget().getTargetLowering(); unsigned SP = TLI->getStackPointerRegisterToSaveRestore(); diff --git a/llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir b/llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir index 8d121c3a30b91..adc43d96a961b 100644 --- a/llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir +++ b/llvm/test/DebugInfo/MIR/X86/entry-value-of-modified-param.mir @@ -19,7 +19,6 @@ # CHECK: ![[ARG_A:.*]] = !DILocalVariable(name: "a" # CHECK: ![[ARG_B:.*]] = !DILocalVariable(name: "b" # CHECK: ![[ARG_C:.*]] = !DILocalVariable(name: "c" -# CHECK: DBG_VALUE $edi, $noreg, ![[ARG_A]], !DIExpression(DW_OP_LLVM_entry_value, 1) # CHECK: DBG_VALUE $edx, $noreg, ![[ARG_C]], !DIExpression(DW_OP_LLVM_entry_value, 1) # CHECK: DBG_VALUE $edi, $noreg, ![[ARG_A]], !DIExpression(DW_OP_LLVM_entry_value, 1) # CHECK-NOT: DBG_VALUE $esi, $noreg, ![[ARG_B]], !DIExpression(DW_OP_LLVM_entry_value, 1) diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues-ignores-metaInstructions.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues-ignores-metaInstructions.mir new file mode 100644 index 0000000000000..e8c3a994e59d0 --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues-ignores-metaInstructions.mir @@ -0,0 +1,64 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that live-debug-values ignores meta instructions. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.1.bb1: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.2.bb2: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.3.bb3: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + bb.1.bb1: + successors: %bb.2 + renamable $ebx = KILL $ebx + bb.2.bb2: + successors: %bb.3 + renamable $ebx = KILL $ebx + bb.3.bb3: + RETQ $eax, debug-location !17 +... From 6d282b93a4ac4ec9f92d592d83f58dcec716a107 Mon Sep 17 00:00:00 2001 From: Djordje Todorovic Date: Thu, 23 Jan 2020 14:20:19 +0100 Subject: [PATCH 4/5] [DWARF][test] Test all the call-site realted attrs Adding the test for the call site encoding in DWARF5 vs GNU extensions. Some of the attributes were not covered by any test. Differential Revision: https://reviews.llvm.org/D73266 (cherry picked from commit 035c106f378d6d7e54d5e98737d32f0f246316a2) --- .../MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir | 184 ++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir diff --git a/llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir b/llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir new file mode 100644 index 0000000000000..1c5922ce76f0d --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/call-site-gnu-vs-dwarf5-attrs.mir @@ -0,0 +1,184 @@ +# Test the call site encoding in DWARF5 vs GNU extensions. +# +# RUN: llc -dwarf-version 4 -debugger-tune=gdb -debug-entry-values -filetype=obj \ +# RUN: -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s \ +# RUN: | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-GNU +# +# RUN: llc -dwarf-version 5 -debugger-tune=lldb -debug-entry-values -filetype=obj \ +# RUN: -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s \ +# RUN: | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-DWARF5 +# +# RUN: llc -dwarf-version 5 -debug-entry-values -filetype=obj \ +# RUN: -mtriple=x86_64-unknown-unknown -start-after=machineverifier -o - %s \ +# RUN: | llvm-dwarfdump - | FileCheck %s -check-prefixes=CHECK-DWARF5 +# +# This is based on the following reproducer: +# +# extern void fn(); +# extern void fn2(int x); +# extern int fn3(); +# +# int fn1(int (*fn4) ()) { +# fn(); +# fn2(5); +# +# int x = (*fn4)(); +# if (!x) +# return fn3(); +# else +# return -1; +# } +# +# Check GNU extensions: +# +# CHECK-GNU: DW_TAG_subprogram +# CHECK-GNU: DW_AT_GNU_all_call_sites (true) +# CHECK-GNU: DW_TAG_GNU_call_site +# CHECK-GNU-NEXT: DW_AT_abstract_origin +# CHECK-GNU-NEXT: DW_AT_low_pc +# CHECK-GNU: DW_TAG_GNU_call_site_parameter +# CHECK-GNU-NEXT: DW_AT_location +# CHECK-GNU-NEXT: DW_AT_GNU_call_site_value +# CHECK-GNU: DW_TAG_GNU_call_site +# CHECK-GNU-NEXT: DW_AT_GNU_call_site_target +# CHECK-GNU-NEXT: DW_AT_low_pc +# CHECK-GNU: DW_TAG_GNU_call_site +# CHECK-GNU-NEXT: DW_AT_abstract_origin +# CHECK-GNU-NEXT: DW_AT_GNU_tail_call +# +# +# Check DWARF 5: +# +# CHECK-DWARF5: DW_TAG_subprogram +# CHECK-DWARF5: DW_AT_call_all_calls (true) +# CHECK-DWARF5: DW_TAG_call_site +# CHECK-DWARF5-NEXT: DW_AT_call_origin +# CHECK-DWARF5-NEXT: DW_AT_call_return_pc +# CHECK-DWARF5: DW_TAG_call_site_parameter +# CHECK-DWARF5-NEXT: DW_AT_location +# CHECK-DWARF5-NEXT: DW_AT_call_value +# CHECK-DWARF5: DW_TAG_call_site +# CHECK-DWARF5-NEXT: DW_AT_call_target +# CHECK-DWARF5-NEXT: DW_AT_call_return_pc +# CHECK-DWARF5: DW_TAG_call_site +# CHECK-DWARF5-NEXT: DW_AT_call_origin +# CHECK-DWARF5-NEXT: DW_AT_call_tail_call +# +--- | + ; ModuleID = 'call-site-attrs.c' + source_filename = "call-site-attrs.c" + target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" + target triple = "x86_64-unknown-linux-gnu" + ; Function Attrs: nounwind uwtable + define dso_local i32 @fn1(i32 (...)* nocapture %fn4) local_unnamed_addr !dbg !18 { + entry: + call void @llvm.dbg.value(metadata i32 (...)* %fn4, metadata !23, metadata !DIExpression()), !dbg !25 + tail call void (...) @fn(), !dbg !26 + tail call void @fn2(i32 5), !dbg !27 + %call = tail call i32 (...) %fn4(), !dbg !28 + call void @llvm.dbg.value(metadata i32 %call, metadata !24, metadata !DIExpression()), !dbg !25 + %tobool = icmp eq i32 %call, 0, !dbg !29 + br i1 %tobool, label %if.then, label %cleanup, !dbg !31 + + if.then: ; preds = %entry + %call1 = tail call i32 (...) @fn3(), !dbg !32 + ret i32 %call1, !dbg !33 + + cleanup: ; preds = %entry + ret i32 -1, !dbg !33 + } + declare !dbg !4 dso_local void @fn(...) local_unnamed_addr + declare !dbg !7 dso_local void @fn2(i32) local_unnamed_addr + declare !dbg !11 dso_local i32 @fn3(...) local_unnamed_addr + ; Function Attrs: nounwind readnone speculatable willreturn + declare void @llvm.dbg.value(metadata, metadata, metadata) + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!14, !15, !16} + !llvm.ident = !{!17} + + !0 = distinct !DICompileUnit(language: DW_LANG_C99, file: !1, producer: "clang version 11.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, retainedTypes: !3, splitDebugInlining: false, nameTableKind: None) + !1 = !DIFile(filename: "call-site-attrs.c", directory: "/") + !2 = !{} + !3 = !{!4, !7, !11} + !4 = !DISubprogram(name: "fn", scope: !1, file: !1, line: 1, type: !5, spFlags: DISPFlagOptimized, retainedNodes: !2) + !5 = !DISubroutineType(types: !6) + !6 = !{null, null} + !7 = !DISubprogram(name: "fn2", scope: !1, file: !1, line: 2, type: !8, flags: DIFlagPrototyped, spFlags: DISPFlagOptimized, retainedNodes: !2) + !8 = !DISubroutineType(types: !9) + !9 = !{null, !10} + !10 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !11 = !DISubprogram(name: "fn3", scope: !1, file: !1, line: 3, type: !12, spFlags: DISPFlagOptimized, retainedNodes: !2) + !12 = !DISubroutineType(types: !13) + !13 = !{!10, null} + !14 = !{i32 7, !"Dwarf Version", i32 4} + !15 = !{i32 2, !"Debug Info Version", i32 3} + !16 = !{i32 1, !"wchar_size", i32 4} + !17 = !{!"clang version 11.0.0"} + !18 = distinct !DISubprogram(name: "fn1", scope: !1, file: !1, line: 5, type: !19, scopeLine: 5, flags: DIFlagPrototyped | DIFlagAllCallsDescribed, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !22) + !19 = !DISubroutineType(types: !20) + !20 = !{!10, !21} + !21 = !DIDerivedType(tag: DW_TAG_pointer_type, baseType: !12, size: 64) + !22 = !{!23, !24} + !23 = !DILocalVariable(name: "fn4", arg: 1, scope: !18, file: !1, line: 5, type: !21) + !24 = !DILocalVariable(name: "x", scope: !18, file: !1, line: 9, type: !10) + !25 = !DILocation(line: 0, scope: !18) + !26 = !DILocation(line: 6, column: 3, scope: !18) + !27 = !DILocation(line: 7, column: 3, scope: !18) + !28 = !DILocation(line: 9, column: 11, scope: !18) + !29 = !DILocation(line: 10, column: 8, scope: !30) + !30 = distinct !DILexicalBlock(scope: !18, file: !1, line: 10, column: 7) + !31 = !DILocation(line: 10, column: 7, scope: !18) + !32 = !DILocation(line: 11, column: 12, scope: !30) + !33 = !DILocation(line: 14, column: 1, scope: !18) + +... +--- +name: fn1 +callSites: + - { bb: 0, offset: 7, fwdArgRegs: [] } + - { bb: 0, offset: 9, fwdArgRegs: + - { arg: 0, reg: '$edi' } } + - { bb: 0, offset: 11, fwdArgRegs: [] } + - { bb: 2, offset: 7, fwdArgRegs: [] } +body: | + bb.0.entry: + successors: %bb.2(0x30000000), %bb.1(0x50000000) + liveins: $rdi, $rbx + + DBG_VALUE $rdi, $noreg, !23, !DIExpression(), debug-location !25 + frame-setup PUSH64r killed $rbx, implicit-def $rsp, implicit $rsp + CFI_INSTRUCTION def_cfa_offset 16 + CFI_INSTRUCTION offset $rbx, -16 + $rbx = MOV64rr $rdi + DBG_VALUE $rbx, $noreg, !23, !DIExpression(), debug-location !25 + dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al, debug-location !26 + CALL64pcrel32 @fn, csr_64, implicit $rsp, implicit $ssp, implicit $al, implicit-def $rsp, implicit-def $ssp, debug-location !26 + $edi = MOV32ri 5, debug-location !27 + CALL64pcrel32 @fn2, csr_64, implicit $rsp, implicit $ssp, implicit $edi, implicit-def $rsp, implicit-def $ssp, debug-location !27 + dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al, debug-location !28 + CALL64r killed renamable $rbx, csr_64, implicit $rsp, implicit $ssp, implicit $al, implicit-def $rsp, implicit-def $ssp, implicit-def $eax, debug-location !28 + DBG_VALUE $eax, $noreg, !24, !DIExpression(), debug-location !25 + TEST32rr killed renamable $eax, renamable $eax, implicit-def $eflags, debug-location !29 + JCC_1 %bb.2, 4, implicit $eflags, debug-location !31 + + bb.1.cleanup: + DBG_VALUE $eax, $noreg, !24, !DIExpression(), debug-location !25 + DBG_VALUE $rbx, $noreg, !23, !DIExpression(), debug-location !25 + $eax = MOV32ri -1, debug-location !33 + $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !33 + DBG_VALUE $rdi, $noreg, !23, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !25 + CFI_INSTRUCTION def_cfa_offset 8, debug-location !33 + RETQ $eax, debug-location !33 + + bb.2.if.then: + CFI_INSTRUCTION def_cfa_offset 16, debug-location !32 + DBG_VALUE $eax, $noreg, !24, !DIExpression(), debug-location !25 + DBG_VALUE $rbx, $noreg, !23, !DIExpression(), debug-location !25 + dead $eax = XOR32rr undef $eax, undef $eax, implicit-def dead $eflags, implicit-def $al, debug-location !32 + $rbx = frame-destroy POP64r implicit-def $rsp, implicit $rsp, debug-location !32 + DBG_VALUE $rdi, $noreg, !23, !DIExpression(DW_OP_LLVM_entry_value, 1), debug-location !25 + CFI_INSTRUCTION def_cfa_offset 8, debug-location !32 + TAILJMPd64 @fn3, csr_64, implicit $rsp, implicit $ssp, implicit $rsp, implicit $ssp, implicit $al, debug-location !32 + +... From 67d513ab11cdf7c84c223c4aba11c97ffc742a8c Mon Sep 17 00:00:00 2001 From: Tom Weaver Date: Tue, 14 Jan 2020 15:51:11 +0000 Subject: [PATCH 5/5] [DBG][LIVEDEBUGVALUES][NFC] Add Targeted LiveDebugValues Behaviour Tests. Adds 22 distinct tests that exercise the live-debug-values passes expected behaviour. reviewers: aprantl, vsk Differential revision: https://reviews.llvm.org/D72515 (cherry picked from commit e7b2d9f4702cb8882aa275bcb8eab37be17601e1) --- .../MIR/X86/livedebugvalues_basic_diamond.mir | 67 +++++++++++++++ ...ebugvalues_basic_diamond_match_clobber.mir | 67 +++++++++++++++ ...vedebugvalues_basic_diamond_match_move.mir | 73 ++++++++++++++++ ...edebugvalues_basic_diamond_one_clobber.mir | 65 +++++++++++++++ ...livedebugvalues_basic_diamond_one_move.mir | 68 +++++++++++++++ .../MIR/X86/livedebugvalues_basic_loop.mir | 66 +++++++++++++++ .../MIR/X86/livedebugvalues_bb_to_bb.mir | 65 +++++++++++++++ .../livedebugvalues_bb_to_bb_clobbered.mir | 61 ++++++++++++++ ...vedebugvalues_bb_to_bb_move_to_clobber.mir | 68 +++++++++++++++ .../MIR/X86/livedebugvalues_loop_break.mir | 74 +++++++++++++++++ .../livedebugvalues_loop_break_clobbered.mir | 66 +++++++++++++++ .../X86/livedebugvalues_loop_clobbered.mir | 63 ++++++++++++++ .../MIR/X86/livedebugvalues_loop_diamond.mir | 82 ++++++++++++++++++ .../livedebugvalues_loop_diamond_clobber.mir | 73 ++++++++++++++++ .../X86/livedebugvalues_loop_diamond_move.mir | 83 +++++++++++++++++++ .../livedebugvalues_loop_early_clobber.mir | 60 ++++++++++++++ .../X86/livedebugvalues_loop_two_backedge.mir | 74 +++++++++++++++++ ...ebugvalues_loop_two_backedge_clobbered.mir | 66 +++++++++++++++ .../X86/livedebugvalues_loop_within_loop.mir | 81 ++++++++++++++++++ ...debugvalues_loop_within_loop_clobbered.mir | 72 ++++++++++++++++ ...livedebugvalues_loop_within_loop_moved.mir | 75 +++++++++++++++++ ...bugvalues_loop_within_loop_outer_moved.mir | 77 +++++++++++++++++ 22 files changed, 1546 insertions(+) create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond_match_clobber.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond_match_move.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond_one_clobber.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond_one_move.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_loop.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_bb_to_bb.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_bb_to_bb_clobbered.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_bb_to_bb_move_to_clobber.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_break.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_break_clobbered.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_clobbered.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_diamond.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_diamond_clobber.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_diamond_move.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_early_clobber.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_two_backedge.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_two_backedge_clobbered.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_within_loop.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_within_loop_clobbered.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_within_loop_moved.mir create mode 100644 llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_within_loop_outer_moved.mir diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond.mir new file mode 100644 index 0000000000000..4004199ad0482 --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond.mir @@ -0,0 +1,67 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are propogated through a CFG containing + ; a diamond that doesn't move or clobber their locations. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.1.bb1: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.2.bb2: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.3.bb3: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1, %bb.2 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + JCC_1 %bb.2, 4, implicit killed $eflags + bb.1.bb1: + successors: %bb.3 + $eax = MOV32ri 0, debug-location !17 + JMP_1 %bb.3 + bb.2.bb2: + successors: %bb.3 + $eax = MOV32ri 0, debug-location !17 + bb.3.bb3: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond_match_clobber.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond_match_clobber.mir new file mode 100644 index 0000000000000..063b7f450e08e --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond_match_clobber.mir @@ -0,0 +1,67 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are only propogated into the top blocks of + ; a diamond when the location is clobbered and not into the successor block. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.1.bb1: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-NEXT: $ebx = MOV32ri 0, debug-location !17 + ; CHECK-LABEL: bb.2.bb2: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-NEXT: $ebx = MOV32ri 0, debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1, %bb.2 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + JCC_1 %bb.2, 4, implicit killed $eflags + bb.1.bb1: + successors: %bb.3 + $ebx = MOV32ri 0, debug-location !17 + JMP_1 %bb.3 + bb.2.bb2: + successors: %bb.3 + $ebx = MOV32ri 0, debug-location !17 + bb.3.bb3: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond_match_move.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond_match_move.mir new file mode 100644 index 0000000000000..8e530c89db621 --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond_match_move.mir @@ -0,0 +1,73 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are propogated correctly through a + ; diamond CFG when the location is moved by another instruction. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.1.bb1: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-NEXT: $eax = MOV32ri 0, debug-location !17 + ; CHECK-NEXT: DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.2.bb2: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-NEXT: $eax = MOV32ri 0, debug-location !17 + ; CHECK-NEXT: DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.3.bb3: + ; CHECK: DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1, %bb.2 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + JCC_1 %bb.2, 4, implicit killed $eflags + bb.1.bb1: + successors: %bb.3 + $eax = MOV32ri 0, debug-location !17 + DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + JMP_1 %bb.3 + bb.2.bb2: + successors: %bb.3 + $eax = MOV32ri 0, debug-location !17 + DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + bb.3.bb3: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond_one_clobber.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond_one_clobber.mir new file mode 100644 index 0000000000000..a89546800a217 --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond_one_clobber.mir @@ -0,0 +1,65 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are not propagated into a successor block + ; of a diamond CFG that clobbers its location. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.1.bb1: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.2.bb2: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1, %bb.2 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + JCC_1 %bb.2, 4, implicit killed $eflags + bb.1.bb1: + successors: %bb.3 + $ebx = MOV32ri 0, debug-location !17 + JMP_1 %bb.3 + bb.2.bb2: + successors: %bb.3 + $eax = MOV32ri 0, debug-location !17 + bb.3.bb3: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond_one_move.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond_one_move.mir new file mode 100644 index 0000000000000..4b9b70455407b --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_diamond_one_move.mir @@ -0,0 +1,68 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are not propagated into a successor block + ; of a diamond CFG that moves its location. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.1.bb1: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-NEXT: $eax = MOV32ri 0, debug-location !17 + ; CHECK: DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.2.bb2: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1, %bb.2 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + JCC_1 %bb.2, 4, implicit killed $eflags + bb.1.bb1: + successors: %bb.3 + $eax = MOV32ri 0, debug-location !17 + DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + JMP_1 %bb.3 + bb.2.bb2: + successors: %bb.3 + $eax = MOV32ri 0, debug-location !17 + bb.3.bb3: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_loop.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_loop.mir new file mode 100644 index 0000000000000..ba2d31ea0b462 --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_basic_loop.mir @@ -0,0 +1,66 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are propagated throughout a CFG with a + ; loop that doesn't move or clobber its location. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.1.bb1: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.2.bb2: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.3.bb3: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + bb.1.bb1: + successors: %bb.2 + $eax = MOV32ri 0, debug-location !17 + bb.2.bb2: + successors: %bb.1, %bb.3 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.1, 4, implicit killed $eflags + bb.3.bb3: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_bb_to_bb.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_bb_to_bb.mir new file mode 100644 index 0000000000000..2801df4832e33 --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_bb_to_bb.mir @@ -0,0 +1,65 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are propagated throughout a basic + ; sequential CFG. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.1.bb1: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.2.bb2: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.3.bb3: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + bb.1.bb1: + successors: %bb.2 + $eax = MOV32ri 0, debug-location !17 + bb.2.bb2: + successors: %bb.3 + $eax = MOV32ri 0, debug-location !17 + bb.3.bb3: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_bb_to_bb_clobbered.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_bb_to_bb_clobbered.mir new file mode 100644 index 0000000000000..d1cacff032e13 --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_bb_to_bb_clobbered.mir @@ -0,0 +1,61 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are propagated into basic blocks with no + ; control flow when it's location is clobbered. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.1.bb1: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + bb.1.bb1: + successors: %bb.2 + $ebx = MOV32ri 0, debug-location !17 + bb.2.bb2: + successors: %bb.3 + $eax = MOV32ri 0, debug-location !17 + bb.3.bb3: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_bb_to_bb_move_to_clobber.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_bb_to_bb_move_to_clobber.mir new file mode 100644 index 0000000000000..c1cb8d5daa958 --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_bb_to_bb_move_to_clobber.mir @@ -0,0 +1,68 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are correctly propagated into blocks with + ; no control flow when a location is moved and then clobbered. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.1.bb1: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-NEXT: $eax = MOV32ri 0, debug-location !17 + ; CHECK: DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.2.bb2: + ; CHECK: DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.3.bb3: + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + bb.1.bb1: + successors: %bb.2 + $eax = MOV32ri 0, debug-location !17 + DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + $ebx = MOV32ri 0, debug-location !17 + bb.2.bb2: + successors: %bb.3 + $eax = MOV32ri 0, debug-location !17 + bb.3.bb3: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_break.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_break.mir new file mode 100644 index 0000000000000..7860517adaf08 --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_break.mir @@ -0,0 +1,74 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are correctly propagated into a loop with + ; break. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.1.bb1: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.2.bb2: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.3.bb3: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.4.bb4: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + br label %bb4, !dbg !17 + bb4: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + bb.1.bb1: + successors: %bb.2 + $eax = MOV32ri 0, debug-location !17 + bb.2.bb2: + successors: %bb.3, %bb.4 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.4, 4, implicit killed $eflags + bb.3.bb3: + successors: %bb.1, %bb.4 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.1, 4, implicit killed $eflags + bb.4.bb4: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_break_clobbered.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_break_clobbered.mir new file mode 100644 index 0000000000000..b4dea6ccbf700 --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_break_clobbered.mir @@ -0,0 +1,66 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are correctly propagated when dealing + ; with a loop that clobbers its location and has two exit points (a break). + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + br label %bb4, !dbg !17 + bb4: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + bb.1.bb1: + successors: %bb.2 + $eax = MOV32ri 0, debug-location !17 + bb.2.bb2: + successors: %bb.3, %bb.4 + $ebx = MOV32ri 0, debug-location !17 + JCC_1 %bb.4, 4, implicit killed $eflags + bb.3.bb3: + successors: %bb.1, %bb.4 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.1, 4, implicit killed $eflags + bb.4.bb4: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_clobbered.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_clobbered.mir new file mode 100644 index 0000000000000..47f114f7fe1b8 --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_clobbered.mir @@ -0,0 +1,63 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are not propagated into a loop that + ; clobbers it's location. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0)", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\test") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + + bb.1.bb1: + successors: %bb.2 + $eax = MOV32ri 0, debug-location !17 + + bb.2.bb2: + successors: %bb.1, %bb.3 + $ebx = MOV32ri 0, debug-location !17 + JCC_1 %bb.1, 4, implicit killed $eflags + + bb.3.bb3: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_diamond.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_diamond.mir new file mode 100644 index 0000000000000..9854e05e20dca --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_diamond.mir @@ -0,0 +1,82 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are propagated into a loop with + ; diamond pattern and beyond. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.1.bb1: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.2.bb2: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.3.bb3: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.4.bb4: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.5.bb5: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + br label %bb3, !dbg !17 + bb4: + br label %bb3, !dbg !17 + bb5: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + bb.1.bb1: + successors: %bb.2, %bb.3 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.3, 4, implicit killed $eflags + bb.2.bb2: + successors: %bb.4 + $eax = MOV32ri 0, debug-location !17 + JMP_1 %bb.4 + bb.3.bb3: + successors: %bb.4 + $eax = MOV32ri 0, debug-location !17 + bb.4.bb4: + successors: %bb.1, %bb.5 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.1, 4, implicit killed $eflags + bb.5.bb5: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_diamond_clobber.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_diamond_clobber.mir new file mode 100644 index 0000000000000..7e18939870bc7 --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_diamond_clobber.mir @@ -0,0 +1,73 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are not propagated into a loop with + ; diamond pattern that clobbers it's location. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.1.bb1: + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + br label %bb3, !dbg !17 + bb4: + br label %bb3, !dbg !17 + bb5: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + bb.1.bb1: + successors: %bb.2, %bb.3 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.3, 4, implicit killed $eflags + bb.2.bb2: + successors: %bb.4 + $eax = MOV32ri 0, debug-location !17 + JMP_1 %bb.4 + bb.3.bb3: + successors: %bb.4 + $ebx = MOV32ri 0, debug-location !17 + bb.4.bb4: + successors: %bb.1, %bb.5 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.1, 4, implicit killed $eflags + bb.5.bb5: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_diamond_move.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_diamond_move.mir new file mode 100644 index 0000000000000..ed7bdcffd881b --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_diamond_move.mir @@ -0,0 +1,83 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are propagated into a loop with + ; diamond pattern but not beyond. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.1.bb1: + ; CHECK: DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.2.bb2: + ; CHECK: DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.3.bb3: + ; CHECK: DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.4.bb4: + ; CHECK: DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.5.bb5: + ; CHECK: DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + br label %bb3, !dbg !17 + bb4: + br label %bb3, !dbg !17 + bb5: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + bb.1.bb1: + successors: %bb.2, %bb.3 + $eax = MOV32ri 0, debug-location !17 + DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + JCC_1 %bb.3, 4, implicit killed $eflags + bb.2.bb2: + successors: %bb.4 + $ebx = MOV32ri 0, debug-location !17 + JMP_1 %bb.4 + bb.3.bb3: + successors: %bb.4 + $ebx = MOV32ri 0, debug-location !17 + bb.4.bb4: + successors: %bb.1, %bb.5 + $ebx = MOV32ri 0, debug-location !17 + JCC_1 %bb.1, 4, implicit killed $eflags + bb.5.bb5: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_early_clobber.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_early_clobber.mir new file mode 100644 index 0000000000000..ff66eba762cb6 --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_early_clobber.mir @@ -0,0 +1,60 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are not propagated into a loop that + ; clobbers it's location. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + bb.1.bb1: + successors: %bb.2 + $ebx = MOV32ri 0, debug-location !17 + bb.2.bb2: + successors: %bb.1, %bb.3 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.1, 4, implicit killed $eflags + bb.3.bb3: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_two_backedge.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_two_backedge.mir new file mode 100644 index 0000000000000..0989ee335b083 --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_two_backedge.mir @@ -0,0 +1,74 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are prapogated into a loop that has two + ; backedges and beyond. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.1.bb1: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.2.bb2: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.3.bb3: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.4.bb4: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + br label %bb4, !dbg !17 + bb4: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + bb.1.bb1: + successors: %bb.2 + $eax = MOV32ri 0, debug-location !17 + bb.2.bb2: + successors: %bb.1, %bb.3 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.1, 4, implicit killed $eflags + bb.3.bb3: + successors: %bb.1, %bb.4 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.1, 4, implicit killed $eflags + bb.4.bb4: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_two_backedge_clobbered.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_two_backedge_clobbered.mir new file mode 100644 index 0000000000000..0148af9155597 --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_two_backedge_clobbered.mir @@ -0,0 +1,66 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are not propagated into loops that clobber + ; their locations and have two backedges. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + br label %bb4, !dbg !17 + bb4: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + bb.1.bb1: + successors: %bb.2 + $eax = MOV32ri 0, debug-location !17 + bb.2.bb2: + successors: %bb.1, %bb.3 + $ebx = MOV32ri 0, debug-location !17 + JCC_1 %bb.1, 4, implicit killed $eflags + bb.3.bb3: + successors: %bb.1, %bb.4 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.1, 4, implicit killed $eflags + bb.4.bb4: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_within_loop.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_within_loop.mir new file mode 100644 index 0000000000000..f15275ed60a90 --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_within_loop.mir @@ -0,0 +1,81 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are propagated into loops within loops. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.1.bb1: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.2.bb2: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.3.bb3: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.4.bb4: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.5.bb5: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + br label %bb3, !dbg !17 + bb4: + br label %bb3, !dbg !17 + bb5: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + bb.1.bb1: + successors: %bb.2, %bb.4 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.4, 4, implicit killed $eflags + bb.2.bb2: + successors: %bb.3 + $eax = MOV32ri 0, debug-location !17 + bb.3.bb3: + successors: %bb.2, %bb.4 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.2, 4, implicit killed $eflags + bb.4.bb4: + successors: %bb.1, %bb.5 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.1, 4, implicit killed $eflags + bb.5.bb5: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_within_loop_clobbered.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_within_loop_clobbered.mir new file mode 100644 index 0000000000000..78330d52c7cfe --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_within_loop_clobbered.mir @@ -0,0 +1,72 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are not propagated into loops with inner + ; loops that clobber their locations. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + br label %bb3, !dbg !17 + bb4: + br label %bb3, !dbg !17 + bb5: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + bb.1.bb1: + successors: %bb.2, %bb.4 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.4, 4, implicit killed $eflags + bb.2.bb2: + successors: %bb.3 + $eax = MOV32ri 0, debug-location !17 + bb.3.bb3: + successors: %bb.2, %bb.4 + $ebx = MOV32ri 0, debug-location !17 + JCC_1 %bb.2, 4, implicit killed $eflags + bb.4.bb4: + successors: %bb.1, %bb.5 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.1, 4, implicit killed $eflags + bb.5.bb5: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_within_loop_moved.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_within_loop_moved.mir new file mode 100644 index 0000000000000..da624928c3aa8 --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_within_loop_moved.mir @@ -0,0 +1,75 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are not propagated into loops with inner + ; loops that move their locations. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.3.bb3: + ; CHECK: DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + br label %bb3, !dbg !17 + bb4: + br label %bb3, !dbg !17 + bb5: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + bb.1.bb1: + successors: %bb.2, %bb.4 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.4, 4, implicit killed $eflags + bb.2.bb2: + successors: %bb.3 + $eax = MOV32ri 0, debug-location !17 + bb.3.bb3: + successors: %bb.2, %bb.4 + $eax = MOV32ri 0, debug-location !17 + DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + JCC_1 %bb.2, 4, implicit killed $eflags + bb.4.bb4: + successors: %bb.1, %bb.5 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.1, 4, implicit killed $eflags + bb.5.bb5: + RETQ $eax, debug-location !17 +... diff --git a/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_within_loop_outer_moved.mir b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_within_loop_outer_moved.mir new file mode 100644 index 0000000000000..12f22df63b141 --- /dev/null +++ b/llvm/test/DebugInfo/MIR/X86/livedebugvalues_loop_within_loop_outer_moved.mir @@ -0,0 +1,77 @@ +--- | + ; RUN: llc %s -march=x86-64 -run-pass=livedebugvalues -o - | FileCheck %s -implicit-check-not=DBG_VALUE + + ; Check that DBG_VALUE instructions are not propogated into loops with inner + ; loops that move their locations. + + ; CHECK-LABEL: bb.0.entry: + ; CHECK: DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.4.bb4: + ; CHECK: DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + ; CHECK-LABEL: bb.5.bb5: + ; CHECK: DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + + define i32 @_Z8bb_to_bb() local_unnamed_addr !dbg !12 { + entry: + br label %bb1, !dbg !17 + bb1: + br label %bb2, !dbg !17 + bb2: + br label %bb3, !dbg !17 + bb3: + br label %bb3, !dbg !17 + bb4: + br label %bb3, !dbg !17 + bb5: + ret i32 0, !dbg !17 + } + + !llvm.dbg.cu = !{!0} + !llvm.module.flags = !{!7, !8, !9, !10} + !llvm.ident = !{!11} + !0 = distinct !DICompileUnit(language: DW_LANG_C_plus_plus, file: !1, producer: "clang version 10.0.0", isOptimized: true, runtimeVersion: 0, emissionKind: FullDebug, enums: !2, globals: !3, debugInfoForProfiling: true, nameTableKind: None) + !1 = !DIFile(filename: "main.cpp", directory: "F:\") + !2 = !{} + !3 = !{!4} + !4 = !DIGlobalVariableExpression(var: !5, expr: !DIExpression()) + !5 = distinct !DIGlobalVariable(name: "start", scope: !0, file: !1, line: 4, type: !6, isLocal: false, isDefinition: true) + !6 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed) + !7 = !{i32 2, !"Dwarf Version", i32 4} + !8 = !{i32 2, !"Debug Info Version", i32 3} + !9 = !{i32 1, !"wchar_size", i32 2} + !10 = !{i32 7, !"PIC Level", i32 2} + !11 = !{!"clang version 10.0.0"} + !12 = distinct !DISubprogram(name: "bb_to_bb", linkageName: "bb_to_bb", scope: !1, file: !1, line: 6, type: !13, scopeLine: 6, flags: DIFlagPrototyped, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !0, retainedNodes: !15) + !13 = !DISubroutineType(types: !14) + !14 = !{!6, !6} + !15 = !{!16} + !16 = !DILocalVariable(name: "myVar", scope: !12, file: !1, line: 7, type: !6) + !17 = !DILocation(line: 10, scope: !12) + +... +--- +name: _Z8bb_to_bb +body: | + bb.0.entry: + successors: %bb.1 + $ebx = MOV32ri 0, debug-location !17 + DBG_VALUE $ebx, $noreg, !16, !DIExpression(), debug-location !17 + bb.1.bb1: + successors: %bb.2, %bb.4 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.4, 4, implicit killed $eflags + bb.2.bb2: + successors: %bb.3 + $eax = MOV32ri 0, debug-location !17 + bb.3.bb3: + successors: %bb.2, %bb.4 + $eax = MOV32ri 0, debug-location !17 + JCC_1 %bb.2, 4, implicit killed $eflags + bb.4.bb4: + successors: %bb.1, %bb.5 + $eax = MOV32ri 0, debug-location !17 + DBG_VALUE $eax, $noreg, !16, !DIExpression(), debug-location !17 + JCC_1 %bb.1, 4, implicit killed $eflags + bb.5.bb5: + RETQ $eax, debug-location !17 +...