From a3437647dc6996499db4823c31242184c93e6e2e Mon Sep 17 00:00:00 2001 From: Argyrios Kyrtzidis Date: Wed, 20 May 2009 22:57:17 +0000 Subject: Introduce DebugScope which gets embedded into the machine instructions' DebugLoc. DebugScope refers to a debug region, function or block. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@72191 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/CodeGen/DebugLoc.cpp | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 lib/CodeGen/DebugLoc.cpp (limited to 'lib/CodeGen/DebugLoc.cpp') diff --git a/lib/CodeGen/DebugLoc.cpp b/lib/CodeGen/DebugLoc.cpp new file mode 100644 index 0000000000..bc1a5b1340 --- /dev/null +++ b/lib/CodeGen/DebugLoc.cpp @@ -0,0 +1,38 @@ +//===-- DebugLoc.cpp ------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is distributed under the University of Illinois Open Source +// License. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// +// +// Implementation for DebugScopeTracker. +// +//===----------------------------------------------------------------------===// + +#include "llvm/CodeGen/DebugLoc.h" +#include "llvm/CodeGen/MachineFunction.h" +using namespace llvm; + +/// EnterDebugScope - Start a new debug scope. ScopeGV can be a DISubprogram +/// or a DIBlock. +void DebugScopeTracker::EnterDebugScope(GlobalVariable *ScopeGV, + MachineFunction &MF) { + assert(ScopeGV && "GlobalVariable for scope is null!"); + CurScope = MF.CreateDebugScope(ScopeGV, CurScope); +} + +/// ExitDebugScope - "Pop" a DISubprogram or a DIBlock. +void DebugScopeTracker::ExitDebugScope(GlobalVariable *ScopeGV, + MachineFunction &MF) { + assert(ScopeGV && "GlobalVariable for scope is null!"); + assert(!CurScope.isInvalid() && "Mismatched region.end ?"); + // We may have skipped a region.end because it was in an unreachable block. + // Go up the scope chain until we reach the scope that ScopeGV points to. + DebugScopeInfo DSI; + do { + DSI = MF.getDebugScopeInfo(CurScope); + CurScope = DSI.Parent; + } while (!DSI.Parent.isInvalid() && DSI.GV != ScopeGV); +} -- cgit v1.2.3-70-g09d2