LLVM 24.0.0git
LiveDebugVariables.h
Go to the documentation of this file.
1//===- LiveDebugVariables.h - Tracking debug info variables -----*- C++ -*-===//
2//
3// 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
6//
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
20#ifndef LLVM_CODEGEN_LIVEDEBUGVARIABLES_H
21#define LLVM_CODEGEN_LIVEDEBUGVARIABLES_H
22
24#include "llvm/IR/PassManager.h"
27#include <memory>
28
29namespace llvm {
30
31template <typename T> class ArrayRef;
32class LiveIntervals;
33class SlotIndexes;
34class VirtRegMap;
35
37
38public:
39 class LDVImpl;
43
45 /// splitRegister - Move any user variables in OldReg to the live ranges in
46 /// NewRegs where they are live. Mark the values as unavailable where no new
47 /// register is live.
49 LiveIntervals &LIS);
50
51 /// canonicalizeIndexes - Replace every SlotIndex held by this analysis that
52 /// refers to an erased instruction. Described locations do not change, as a
53 /// stale index already resolves to the same position at the point of use, but
54 /// intervals resolving to one position now emit a single DBG_VALUE rather
55 /// than identical consecutive ones.
57
58 /// emitDebugValues - Emit new DBG_VALUE instructions reflecting the changes
59 /// that happened during register allocation.
60 /// @param VRM Rename virtual registers according to map.
62
63#if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
64 /// dump - Print data structures to dbgs().
65 void dump() const;
66#endif
67
68 LLVM_ABI void print(raw_ostream &OS) const;
69
71
73 MachineFunctionAnalysisManager::Invalidator &Inv);
74
75private:
76 std::unique_ptr<LDVImpl> PImpl;
77};
78
80 std::unique_ptr<LiveDebugVariables> Impl;
81
82public:
83 static char ID; // Pass identification, replacement for typeid
84
86
88
89 LiveDebugVariables &getLDV() { return *Impl; }
90 const LiveDebugVariables &getLDV() const { return *Impl; }
91
92 void releaseMemory() override {
93 if (Impl)
94 Impl->releaseMemory();
95 }
96 void getAnalysisUsage(AnalysisUsage &) const override;
97
99 return MachineFunctionProperties().setTracksDebugUserValues();
100 }
101};
102
104 : public AnalysisInfoMixin<LiveDebugVariablesAnalysis> {
106 static AnalysisKey Key;
107
108public:
110
112 return MachineFunctionProperties().setTracksDebugUserValues();
113 }
114
117};
118
120 : public RequiredPassInfoMixin<LiveDebugVariablesPrinterPass> {
121 raw_ostream &OS;
122
123public:
125
128};
129} // end namespace llvm
130
131#endif // LLVM_CODEGEN_LIVEDEBUGVARIABLES_H
#define LLVM_ABI
Definition Compiler.h:215
This header defines various interfaces for pass management in LLVM.
Represent the analysis usage information of a pass.
Represent a constant reference to an array (0 or more elements consecutively in memory),...
Definition ArrayRef.h:40
MachineFunctionProperties getSetProperties() const
LLVM_ABI Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
LLVM_ABI PreservedAnalyses run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM)
const LiveDebugVariables & getLDV() const
void releaseMemory() override
releaseMemory() - This member can be implemented by a pass if it wants to be able to release its memo...
MachineFunctionProperties getSetProperties() const override
bool runOnMachineFunction(MachineFunction &) override
runOnMachineFunction - This method must be overloaded to perform the desired machine code transformat...
LLVM_ABI void canonicalizeIndexes(const SlotIndexes &SI)
canonicalizeIndexes - Replace every SlotIndex held by this analysis that refers to an erased instruct...
LLVM_ABI ~LiveDebugVariables()
void dump() const
dump - Print data structures to dbgs().
LLVM_ABI void splitRegister(Register OldReg, ArrayRef< Register > NewRegs, LiveIntervals &LIS)
splitRegister - Move any user variables in OldReg to the live ranges in NewRegs where they are live.
LLVM_ABI LiveDebugVariables()
Implementation of the LiveDebugVariables pass.
LLVM_ABI void print(raw_ostream &OS) const
LLVM_ABI void analyze(MachineFunction &MF, LiveIntervals *LIS)
LLVM_ABI LiveDebugVariables(LiveDebugVariables &&)
LLVM_ABI void emitDebugValues(VirtRegMap *VRM)
emitDebugValues - Emit new DBG_VALUE instructions reflecting the changes that happened during registe...
LLVM_ABI bool invalidate(MachineFunction &MF, const PreservedAnalyses &PA, MachineFunctionAnalysisManager::Invalidator &Inv)
Properties which a MachineFunction may have at a given point in time.
A set of analyses that are preserved following a run of a transformation pass.
Definition Analysis.h:112
Wrapper class representing virtual and physical registers.
Definition Register.h:20
SlotIndexes pass.
This class implements an extremely fast bulk output stream that can only output to a stream.
Definition raw_ostream.h:53
This is an optimization pass for GlobalISel generic memory operations.
AnalysisManager< MachineFunction > MachineFunctionAnalysisManager
A CRTP mix-in that provides informational APIs needed for analysis passes.
A special type used by analysis passes to provide an address that identifies that particular analysis...
Definition Analysis.h:29
A CRTP mix-in for passes that should not be skipped.