blob: aa35880b063a7e90c9c3e3ed2fa9711b07dfeb93 [file] [log] [blame]
Eugene Zelenko5df3d892017-08-24 21:21:39 +00001//===- LiveDebugVariables.h - Tracking debug info variables -----*- C++ -*-===//
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +00002//
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
24#include "llvm/CodeGen/MachineFunctionPass.h"
Eugene Zelenko5df3d892017-08-24 21:21:39 +000025#include "llvm/Support/Compiler.h"
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000026
27namespace llvm {
28
Mehdi Aminib550cb12016-04-18 09:17:29 +000029template <typename T> class ArrayRef;
Mark Laceyf9ea8852013-08-14 23:50:04 +000030class LiveIntervals;
Jakob Stoklund Olesenafc2bc22010-12-03 21:47:10 +000031class VirtRegMap;
32
Benjamin Kramerf4c20252015-07-01 14:47:39 +000033class LLVM_LIBRARY_VISIBILITY LiveDebugVariables : public MachineFunctionPass {
Eugene Zelenko5df3d892017-08-24 21:21:39 +000034 void *pImpl = nullptr;
Duncan P. N. Exon Smithed557b52015-04-17 23:20:10 +000035
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000036public:
37 static char ID; // Pass identification, replacement for typeid
38
39 LiveDebugVariables();
Alexander Kornienkof817c1c2015-04-11 02:11:45 +000040 ~LiveDebugVariables() override;
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000041
42 /// renameRegister - Move any user variables in OldReg to NewReg:SubIdx.
43 /// @param OldReg Old virtual register that is going away.
44 /// @param NewReg New register holding the user variables.
45 /// @param SubIdx If NewReg is a virtual register, SubIdx may indicate a sub-
46 /// register.
47 void renameRegister(unsigned OldReg, unsigned NewReg, unsigned SubIdx);
48
Jakob Stoklund Olesenf8da0282011-05-06 18:00:02 +000049 /// splitRegister - Move any user variables in OldReg to the live ranges in
50 /// NewRegs where they are live. Mark the values as unavailable where no new
51 /// register is live.
Mark Laceyf9ea8852013-08-14 23:50:04 +000052 void splitRegister(unsigned OldReg, ArrayRef<unsigned> NewRegs,
53 LiveIntervals &LIS);
Jakob Stoklund Olesenf8da0282011-05-06 18:00:02 +000054
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000055 /// emitDebugValues - Emit new DBG_VALUE instructions reflecting the changes
56 /// that happened during register allocation.
Jakob Stoklund Olesenafc2bc22010-12-03 21:47:10 +000057 /// @param VRM Rename virtual registers according to map.
58 void emitDebugValues(VirtRegMap *VRM);
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000059
Jakob Stoklund Olesen9ec20112010-12-02 18:15:44 +000060 /// dump - Print data structures to dbgs().
Sam Clegg705f7982017-06-21 22:19:17 +000061 void dump() const;
Jakob Stoklund Olesen9ec20112010-12-02 18:15:44 +000062
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000063private:
Craig Topper4584cd52014-03-07 09:26:03 +000064 bool runOnMachineFunction(MachineFunction &) override;
65 void releaseMemory() override;
66 void getAnalysisUsage(AnalysisUsage &) const override;
David Blaikie2f040112014-07-25 16:10:16 +000067 bool doInitialization(Module &) override;
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000068};
69
Eugene Zelenko5df3d892017-08-24 21:21:39 +000070} // end namespace llvm
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000071
Eugene Zelenko5df3d892017-08-24 21:21:39 +000072#endif // LLVM_LIB_CODEGEN_LIVEDEBUGVARIABLES_H