File indexing completed on 2026-05-10 08:43:29
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020 #ifndef LLVM_CODEGEN_LIVEDEBUGVARIABLES_H
0021 #define LLVM_CODEGEN_LIVEDEBUGVARIABLES_H
0022
0023 #include "llvm/CodeGen/MachineFunctionPass.h"
0024 #include "llvm/IR/PassManager.h"
0025 #include "llvm/Support/Compiler.h"
0026 #include "llvm/Support/raw_ostream.h"
0027 #include <memory>
0028
0029 namespace llvm {
0030
0031 template <typename T> class ArrayRef;
0032 class LiveIntervals;
0033 class VirtRegMap;
0034
0035 class LiveDebugVariables {
0036
0037 public:
0038 class LDVImpl;
0039 LiveDebugVariables();
0040 ~LiveDebugVariables();
0041 LiveDebugVariables(LiveDebugVariables &&);
0042
0043 void analyze(MachineFunction &MF, LiveIntervals *LIS);
0044
0045
0046
0047 void splitRegister(Register OldReg, ArrayRef<Register> NewRegs,
0048 LiveIntervals &LIS);
0049
0050
0051
0052
0053 void emitDebugValues(VirtRegMap *VRM);
0054
0055 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
0056
0057 void dump() const;
0058 #endif
0059
0060 void print(raw_ostream &OS) const;
0061
0062 void releaseMemory();
0063
0064 bool invalidate(MachineFunction &MF, const PreservedAnalyses &PA,
0065 MachineFunctionAnalysisManager::Invalidator &Inv);
0066
0067 private:
0068 std::unique_ptr<LDVImpl> PImpl;
0069 };
0070
0071 class LiveDebugVariablesWrapperLegacy : public MachineFunctionPass {
0072 std::unique_ptr<LiveDebugVariables> Impl;
0073
0074 public:
0075 static char ID;
0076
0077 LiveDebugVariablesWrapperLegacy();
0078
0079 bool runOnMachineFunction(MachineFunction &) override;
0080
0081 LiveDebugVariables &getLDV() { return *Impl; }
0082 const LiveDebugVariables &getLDV() const { return *Impl; }
0083
0084 void releaseMemory() override {
0085 if (Impl)
0086 Impl->releaseMemory();
0087 }
0088 void getAnalysisUsage(AnalysisUsage &) const override;
0089
0090 MachineFunctionProperties getSetProperties() const override {
0091 return MachineFunctionProperties().set(
0092 MachineFunctionProperties::Property::TracksDebugUserValues);
0093 }
0094 };
0095
0096 class LiveDebugVariablesAnalysis
0097 : public AnalysisInfoMixin<LiveDebugVariablesAnalysis> {
0098 friend AnalysisInfoMixin<LiveDebugVariablesAnalysis>;
0099 static AnalysisKey Key;
0100
0101 public:
0102 using Result = LiveDebugVariables;
0103
0104 MachineFunctionProperties getSetProperties() const {
0105 return MachineFunctionProperties().set(
0106 MachineFunctionProperties::Property::TracksDebugUserValues);
0107 }
0108
0109 Result run(MachineFunction &MF, MachineFunctionAnalysisManager &MFAM);
0110 };
0111
0112 class LiveDebugVariablesPrinterPass
0113 : public PassInfoMixin<LiveDebugVariablesPrinterPass> {
0114 raw_ostream &OS;
0115
0116 public:
0117 LiveDebugVariablesPrinterPass(raw_ostream &OS) : OS(OS) {}
0118
0119 PreservedAnalyses run(MachineFunction &MF,
0120 MachineFunctionAnalysisManager &MFAM);
0121 };
0122 }
0123
0124 #endif