blob: 7ec0d17e42d61d6a006b1083faaf10c44b7e4d8c [file] [log] [blame]
Jakob Stoklund Olesenbb7b23f2010-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
21#ifndef LLVM_CODEGEN_LIVEDEBUGVARIABLES_H
22#define LLVM_CODEGEN_LIVEDEBUGVARIABLES_H
23
Jakob Stoklund Olesenf42b6612011-05-06 18:00:02 +000024#include "llvm/ADT/ArrayRef.h"
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -070025#include "llvm/IR/DebugInfo.h"
Jakob Stoklund Olesenbb7b23f2010-11-30 02:17:10 +000026#include "llvm/CodeGen/MachineFunctionPass.h"
27
28namespace llvm {
29
Jakob Stoklund Olesenf42b6612011-05-06 18:00:02 +000030class LiveInterval;
Mark Lacey1feb5852013-08-14 23:50:04 +000031class LiveIntervals;
Jakob Stoklund Olesen42acf062010-12-03 21:47:10 +000032class VirtRegMap;
33
Benjamin Kramer55c06ae2013-09-11 18:05:11 +000034class LiveDebugVariables : public MachineFunctionPass {
Jakob Stoklund Olesenbb7b23f2010-11-30 02:17:10 +000035 void *pImpl;
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -070036 DenseMap<const Function*, DISubprogram> FunctionDIs;
Jakob Stoklund Olesenbb7b23f2010-11-30 02:17:10 +000037public:
38 static char ID; // Pass identification, replacement for typeid
39
40 LiveDebugVariables();
Jakob Stoklund Olesen06135162010-12-02 00:37:37 +000041 ~LiveDebugVariables();
Jakob Stoklund Olesenbb7b23f2010-11-30 02:17:10 +000042
43 /// renameRegister - Move any user variables in OldReg to NewReg:SubIdx.
44 /// @param OldReg Old virtual register that is going away.
45 /// @param NewReg New register holding the user variables.
46 /// @param SubIdx If NewReg is a virtual register, SubIdx may indicate a sub-
47 /// register.
48 void renameRegister(unsigned OldReg, unsigned NewReg, unsigned SubIdx);
49
Jakob Stoklund Olesenf42b6612011-05-06 18:00:02 +000050 /// splitRegister - Move any user variables in OldReg to the live ranges in
51 /// NewRegs where they are live. Mark the values as unavailable where no new
52 /// register is live.
Mark Lacey1feb5852013-08-14 23:50:04 +000053 void splitRegister(unsigned OldReg, ArrayRef<unsigned> NewRegs,
54 LiveIntervals &LIS);
Jakob Stoklund Olesenf42b6612011-05-06 18:00:02 +000055
Jakob Stoklund Olesenbb7b23f2010-11-30 02:17:10 +000056 /// emitDebugValues - Emit new DBG_VALUE instructions reflecting the changes
57 /// that happened during register allocation.
Jakob Stoklund Olesen42acf062010-12-03 21:47:10 +000058 /// @param VRM Rename virtual registers according to map.
59 void emitDebugValues(VirtRegMap *VRM);
Jakob Stoklund Olesenbb7b23f2010-11-30 02:17:10 +000060
Jakob Stoklund Olesen30e21282010-12-02 18:15:44 +000061 /// dump - Print data structures to dbgs().
62 void dump();
63
Jakob Stoklund Olesenbb7b23f2010-11-30 02:17:10 +000064private:
65
Stephen Hines36b56882014-04-23 16:57:46 -070066 bool runOnMachineFunction(MachineFunction &) override;
67 void releaseMemory() override;
68 void getAnalysisUsage(AnalysisUsage &) const override;
Stephen Hinesc6a4f5e2014-07-21 00:45:20 -070069 bool doInitialization(Module &) override;
Jakob Stoklund Olesenbb7b23f2010-11-30 02:17:10 +000070
71};
72
73} // namespace llvm
74
75#endif // LLVM_CODEGEN_LIVEDEBUGVARIABLES_H