Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-10 08:43:25

0001 //===----- llvm/CodeGen/GlobalISel/LostDebugLocObserver.h -------*- C++ -*-===//
0002 //
0003 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
0004 // See https://llvm.org/LICENSE.txt for license information.
0005 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
0006 //
0007 //===----------------------------------------------------------------------===//
0008 /// \file
0009 /// Tracks DebugLocs between checkpoints and verifies that they are transferred.
0010 ///
0011 //===----------------------------------------------------------------------===//
0012 #ifndef LLVM_CODEGEN_GLOBALISEL_LOSTDEBUGLOCOBSERVER_H
0013 #define LLVM_CODEGEN_GLOBALISEL_LOSTDEBUGLOCOBSERVER_H
0014 
0015 #include "llvm/ADT/SmallSet.h"
0016 #include "llvm/CodeGen/GlobalISel/GISelChangeObserver.h"
0017 
0018 namespace llvm {
0019 class LostDebugLocObserver : public GISelChangeObserver {
0020   StringRef DebugType;
0021   SmallSet<DebugLoc, 4> LostDebugLocs;
0022   SmallPtrSet<MachineInstr *, 4> PotentialMIsForDebugLocs;
0023   unsigned NumLostDebugLocs = 0;
0024 
0025 public:
0026   LostDebugLocObserver(StringRef DebugType) : DebugType(DebugType) {}
0027 
0028   unsigned getNumLostDebugLocs() const { return NumLostDebugLocs; }
0029 
0030   /// Call this to indicate that it's a good point to assess whether locations
0031   /// have been lost. Typically this will be when a logical change has been
0032   /// completed such as the caller has finished replacing some instructions with
0033   /// alternatives. When CheckDebugLocs is true, the locations will be checked
0034   /// to see if any have been lost since the last checkpoint. When
0035   /// CheckDebugLocs is false, it will just reset ready for the next checkpoint
0036   /// without checking anything. This can be helpful to limit the detection to
0037   /// easy-to-fix portions of an algorithm before allowing more difficult ones.
0038   void checkpoint(bool CheckDebugLocs = true);
0039 
0040   void createdInstr(MachineInstr &MI) override;
0041   void erasingInstr(MachineInstr &MI) override;
0042   void changingInstr(MachineInstr &MI) override;
0043   void changedInstr(MachineInstr &MI) override;
0044 
0045 private:
0046   void analyzeDebugLocations();
0047 };
0048 
0049 } // namespace llvm
0050 #endif // LLVM_CODEGEN_GLOBALISEL_LOSTDEBUGLOCOBSERVER_H