blob: 0cbe10c6a42274cdc10bce6aaee0b1b4b038418c [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//
Chandler Carruth2946cd72019-01-19 08:50:56 +00003// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +00006//
7//===----------------------------------------------------------------------===//
8//
9// This file provides the interface to the LiveDebugVariables analysis.
10//
11// The analysis removes DBG_VALUE instructions for virtual registers and tracks
12// live user variables in a data structure that can be updated during register
13// allocation.
14//
15// After register allocation new DBG_VALUE instructions are emitted to reflect
16// the new locations of user variables.
17//
18//===----------------------------------------------------------------------===//
19
Benjamin Kramera7c40ef2014-08-13 16:26:38 +000020#ifndef LLVM_LIB_CODEGEN_LIVEDEBUGVARIABLES_H
21#define LLVM_LIB_CODEGEN_LIVEDEBUGVARIABLES_H
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000022
23#include "llvm/CodeGen/MachineFunctionPass.h"
Eugene Zelenko5df3d892017-08-24 21:21:39 +000024#include "llvm/Support/Compiler.h"
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000025
26namespace llvm {
27
Mehdi Aminib550cb12016-04-18 09:17:29 +000028template <typename T> class ArrayRef;
Mark Laceyf9ea8852013-08-14 23:50:04 +000029class LiveIntervals;
Jakob Stoklund Olesenafc2bc22010-12-03 21:47:10 +000030class VirtRegMap;
31
Benjamin Kramerf4c20252015-07-01 14:47:39 +000032class LLVM_LIBRARY_VISIBILITY LiveDebugVariables : public MachineFunctionPass {
Eugene Zelenko5df3d892017-08-24 21:21:39 +000033 void *pImpl = nullptr;
Duncan P. N. Exon Smithed557b52015-04-17 23:20:10 +000034
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000035public:
36 static char ID; // Pass identification, replacement for typeid
37
38 LiveDebugVariables();
Alexander Kornienkof817c1c2015-04-11 02:11:45 +000039 ~LiveDebugVariables() override;
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000040
Jakob Stoklund Olesenf8da0282011-05-06 18:00:02 +000041 /// splitRegister - Move any user variables in OldReg to the live ranges in
42 /// NewRegs where they are live. Mark the values as unavailable where no new
43 /// register is live.
Mark Laceyf9ea8852013-08-14 23:50:04 +000044 void splitRegister(unsigned OldReg, ArrayRef<unsigned> NewRegs,
45 LiveIntervals &LIS);
Jakob Stoklund Olesenf8da0282011-05-06 18:00:02 +000046
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000047 /// emitDebugValues - Emit new DBG_VALUE instructions reflecting the changes
48 /// that happened during register allocation.
Jakob Stoklund Olesenafc2bc22010-12-03 21:47:10 +000049 /// @param VRM Rename virtual registers according to map.
50 void emitDebugValues(VirtRegMap *VRM);
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000051
Jakob Stoklund Olesen9ec20112010-12-02 18:15:44 +000052 /// dump - Print data structures to dbgs().
Sam Clegg705f7982017-06-21 22:19:17 +000053 void dump() const;
Jakob Stoklund Olesen9ec20112010-12-02 18:15:44 +000054
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000055private:
Craig Topper4584cd52014-03-07 09:26:03 +000056 bool runOnMachineFunction(MachineFunction &) override;
57 void releaseMemory() override;
58 void getAnalysisUsage(AnalysisUsage &) const override;
David Blaikie2f040112014-07-25 16:10:16 +000059 bool doInitialization(Module &) override;
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000060};
61
Eugene Zelenko5df3d892017-08-24 21:21:39 +000062} // end namespace llvm
Jakob Stoklund Olesend4900a62010-11-30 02:17:10 +000063
Eugene Zelenko5df3d892017-08-24 21:21:39 +000064#endif // LLVM_LIB_CODEGEN_LIVEDEBUGVARIABLES_H