blob: bc1a5b13401d32e4f0f4beb10c4f53bc4395c6cd [file] [log] [blame]
Argyrios Kyrtzidisa3437642009-05-20 22:57:17 +00001//===-- DebugLoc.cpp ------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
5// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
9//
10// Implementation for DebugScopeTracker.
11//
12//===----------------------------------------------------------------------===//
13
14#include "llvm/CodeGen/DebugLoc.h"
15#include "llvm/CodeGen/MachineFunction.h"
16using namespace llvm;
17
18/// EnterDebugScope - Start a new debug scope. ScopeGV can be a DISubprogram
19/// or a DIBlock.
20void DebugScopeTracker::EnterDebugScope(GlobalVariable *ScopeGV,
21 MachineFunction &MF) {
22 assert(ScopeGV && "GlobalVariable for scope is null!");
23 CurScope = MF.CreateDebugScope(ScopeGV, CurScope);
24}
25
26/// ExitDebugScope - "Pop" a DISubprogram or a DIBlock.
27void DebugScopeTracker::ExitDebugScope(GlobalVariable *ScopeGV,
28 MachineFunction &MF) {
29 assert(ScopeGV && "GlobalVariable for scope is null!");
30 assert(!CurScope.isInvalid() && "Mismatched region.end ?");
31 // We may have skipped a region.end because it was in an unreachable block.
32 // Go up the scope chain until we reach the scope that ScopeGV points to.
33 DebugScopeInfo DSI;
34 do {
35 DSI = MF.getDebugScopeInfo(CurScope);
36 CurScope = DSI.Parent;
37 } while (!DSI.Parent.isInvalid() && DSI.GV != ScopeGV);
38}