blob: ac2d1a136bca19db493697e02d9ff73ec86245b2 [file] [log] [blame]
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +00001//===- LiveDebugVariables.h - Tracking debug info variables ----*- c++ -*--===//
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// This file provides the interface to the LiveDebugVariables analysis.
11//
12// The analysis removes DBG_VALUE instructions for virtual registers and tracks
13// live user variables in a data structure that can be updated during register
14// allocation.
15//
16// After register allocation new DBG_VALUE instructions are emitted to reflect
17// the new locations of user variables.
18//
19//===----------------------------------------------------------------------===//
20
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000021#ifndef LLVM_LIB_CODEGEN_LIVEDEBUGVARIABLES_H
22#define LLVM_LIB_CODEGEN_LIVEDEBUGVARIABLES_H
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000023
Jakob Stoklund Olesenf8da0282011-05-06 18:00:02 +000024#include "llvm/ADT/ArrayRef.h"
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000025#include "llvm/CodeGen/MachineFunctionPass.h"
Chandler Carruthd9903882015-01-14 11:23:27 +000026#include "llvm/IR/DebugInfo.h"
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000027
28namespace llvm {
29
Jakob Stoklund Olesenf8da0282011-05-06 18:00:02 +000030class LiveInterval;
Mark Laceyf9ea8852013-08-14 23:50:04 +000031class LiveIntervals;
Jakob Stoklund Olesenafc2bc22010-12-03 21:47:10 +000032class VirtRegMap;
33
Benjamin Kramer079b96e2013-09-11 18:05:11 +000034class LiveDebugVariables : public MachineFunctionPass {
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000035 void *pImpl;
Duncan P. N. Exon Smitha9308c42015-04-29 16:38:44 +000036 DenseMap<const Function *, DISubprogram *> FunctionDIs;
Duncan P. N. Exon Smithed557b52015-04-17 23:20:10 +000037
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000038public:
39 static char ID; // Pass identification, replacement for typeid
40
41 LiveDebugVariables();
Alexander Kornienkof817c1c2015-04-11 02:11:45 +000042 ~LiveDebugVariables() override;
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000043
44 /// renameRegister - Move any user variables in OldReg to NewReg:SubIdx.
45 /// @param OldReg Old virtual register that is going away.
46 /// @param NewReg New register holding the user variables.
47 /// @param SubIdx If NewReg is a virtual register, SubIdx may indicate a sub-
48 /// register.
49 void renameRegister(unsigned OldReg, unsigned NewReg, unsigned SubIdx);
50
Jakob Stoklund Olesenf8da0282011-05-06 18:00:02 +000051 /// splitRegister - Move any user variables in OldReg to the live ranges in
52 /// NewRegs where they are live. Mark the values as unavailable where no new
53 /// register is live.
Mark Laceyf9ea8852013-08-14 23:50:04 +000054 void splitRegister(unsigned OldReg, ArrayRef<unsigned> NewRegs,
55 LiveIntervals &LIS);
Jakob Stoklund Olesenf8da0282011-05-06 18:00:02 +000056
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000057 /// emitDebugValues - Emit new DBG_VALUE instructions reflecting the changes
58 /// that happened during register allocation.
Jakob Stoklund Olesenafc2bc22010-12-03 21:47:10 +000059 /// @param VRM Rename virtual registers according to map.
60 void emitDebugValues(VirtRegMap *VRM);
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000061
Jakob Stoklund Olesen9ec20112010-12-02 18:15:44 +000062 /// dump - Print data structures to dbgs().
63 void dump();
64
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000065private:
66
Craig Topper4584cd52014-03-07 09:26:03 +000067 bool runOnMachineFunction(MachineFunction &) override;
68 void releaseMemory() override;
69 void getAnalysisUsage(AnalysisUsage &) const override;
David Blaikie2f040112014-07-25 16:10:16 +000070 bool doInitialization(Module &) override;
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000071
72};
73
74} // namespace llvm
75
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000076#endif