LiveDebugVariables.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. #ifndef LLVM_LIB_CODEGEN_LIVEDEBUGVARIABLES_H
  20. #define LLVM_LIB_CODEGEN_LIVEDEBUGVARIABLES_H
  21. #include "llvm/CodeGen/MachineFunctionPass.h"
  22. #include "llvm/Support/Compiler.h"
  23. namespace llvm {
  24. template <typename T> class ArrayRef;
  25. class LiveIntervals;
  26. class VirtRegMap;
  27. class LLVM_LIBRARY_VISIBILITY LiveDebugVariables : public MachineFunctionPass {
  28. void *pImpl = nullptr;
  29. public:
  30. static char ID; // Pass identification, replacement for typeid
  31. LiveDebugVariables();
  32. ~LiveDebugVariables() override;
  33. /// splitRegister - Move any user variables in OldReg to the live ranges in
  34. /// NewRegs where they are live. Mark the values as unavailable where no new
  35. /// register is live.
  36. void splitRegister(Register OldReg, ArrayRef<Register> NewRegs,
  37. LiveIntervals &LIS);
  38. /// emitDebugValues - Emit new DBG_VALUE instructions reflecting the changes
  39. /// that happened during register allocation.
  40. /// @param VRM Rename virtual registers according to map.
  41. void emitDebugValues(VirtRegMap *VRM);
  42. /// dump - Print data structures to dbgs().
  43. void dump() const;
  44. private:
  45. bool runOnMachineFunction(MachineFunction &) override;
  46. void releaseMemory() override;
  47. void getAnalysisUsage(AnalysisUsage &) const override;
  48. MachineFunctionProperties getSetProperties() const override {
  49. return MachineFunctionProperties().set(
  50. MachineFunctionProperties::Property::TracksDebugUserValues);
  51. }
  52. };
  53. } // end namespace llvm
  54. #endif // LLVM_LIB_CODEGEN_LIVEDEBUGVARIABLES_H