blob: 0060399c2b04526f837a7fca1b2ab63778a198cd [file] [log] [blame]
Eugene Zelenko2de563a2017-08-24 21:21:39 +00001//===- LiveDebugVariables.h - Tracking debug info variables -----*- C++ -*-===//
Jakob Stoklund Olesenbb7b23f2010-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 Kramer00e08fc2014-08-13 16:26:38 +000021#ifndef LLVM_LIB_CODEGEN_LIVEDEBUGVARIABLES_H
22#define LLVM_LIB_CODEGEN_LIVEDEBUGVARIABLES_H
Jakob Stoklund Olesenbb7b23f2010-11-30 02:17:10 +000023
24#include "llvm/CodeGen/MachineFunctionPass.h"
Eugene Zelenko2de563a2017-08-24 21:21:39 +000025#include "llvm/Support/Compiler.h"
Jakob Stoklund Olesenbb7b23f2010-11-30 02:17:10 +000026
27namespace llvm {
28
Mehdi Aminif6071e12016-04-18 09:17:29 +000029template <typename T> class ArrayRef;
Mark Lacey1feb5852013-08-14 23:50:04 +000030class LiveIntervals;
Jakob Stoklund Olesen42acf062010-12-03 21:47:10 +000031class VirtRegMap;
32
Benjamin Kramerb4537752015-07-01 14:47:39 +000033class LLVM_LIBRARY_VISIBILITY LiveDebugVariables : public MachineFunctionPass {
Eugene Zelenko2de563a2017-08-24 21:21:39 +000034 void *pImpl = nullptr;
Duncan P. N. Exon Smith5d8013642015-04-17 23:20:10 +000035
Jakob Stoklund Olesenbb7b23f2010-11-30 02:17:10 +000036public:
37 static char ID; // Pass identification, replacement for typeid
38
39 LiveDebugVariables();
Alexander Kornienkoc16fc542015-04-11 02:11:45 +000040 ~LiveDebugVariables() override;
Jakob Stoklund Olesenbb7b23f2010-11-30 02:17:10 +000041
Jakob Stoklund Olesenf42b6612011-05-06 18:00:02 +000042 /// splitRegister - Move any user variables in OldReg to the live ranges in
43 /// NewRegs where they are live. Mark the values as unavailable where no new
44 /// register is live.
Mark Lacey1feb5852013-08-14 23:50:04 +000045 void splitRegister(unsigned OldReg, ArrayRef<unsigned> NewRegs,
46 LiveIntervals &LIS);
Jakob Stoklund Olesenf42b6612011-05-06 18:00:02 +000047
Jakob Stoklund Olesenbb7b23f2010-11-30 02:17:10 +000048 /// emitDebugValues - Emit new DBG_VALUE instructions reflecting the changes
49 /// that happened during register allocation.
Jakob Stoklund Olesen42acf062010-12-03 21:47:10 +000050 /// @param VRM Rename virtual registers according to map.
51 void emitDebugValues(VirtRegMap *VRM);
Jakob Stoklund Olesenbb7b23f2010-11-30 02:17:10 +000052
Jakob Stoklund Olesen30e21282010-12-02 18:15:44 +000053 /// dump - Print data structures to dbgs().
Sam Cleggb2092062017-06-21 22:19:17 +000054 void dump() const;
Jakob Stoklund Olesen30e21282010-12-02 18:15:44 +000055
Jakob Stoklund Olesenbb7b23f2010-11-30 02:17:10 +000056private:
Craig Topper9f998de2014-03-07 09:26:03 +000057 bool runOnMachineFunction(MachineFunction &) override;
58 void releaseMemory() override;
59 void getAnalysisUsage(AnalysisUsage &) const override;
David Blaikiee27d5a02014-07-25 16:10:16 +000060 bool doInitialization(Module &) override;
Jakob Stoklund Olesenbb7b23f2010-11-30 02:17:10 +000061};
62
Eugene Zelenko2de563a2017-08-24 21:21:39 +000063} // end namespace llvm
Jakob Stoklund Olesenbb7b23f2010-11-30 02:17:10 +000064
Eugene Zelenko2de563a2017-08-24 21:21:39 +000065#endif // LLVM_LIB_CODEGEN_LIVEDEBUGVARIABLES_H