LLVM  14.0.0git
LostDebugLocObserver.h
Go to the documentation of this file.
1 //===----- llvm/CodeGen/GlobalISel/LostDebugLocObserver.h -------*- 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 /// \file
9 /// Tracks DebugLocs between checkpoints and verifies that they are transferred.
10 ///
11 //===----------------------------------------------------------------------===//
12 #ifndef LLVM_CODEGEN_GLOBALISEL_LOSTDEBUGLOCOBSERVER_H
13 #define LLVM_CODEGEN_GLOBALISEL_LOSTDEBUGLOCOBSERVER_H
14 
15 #include "llvm/ADT/SmallSet.h"
17 
18 namespace llvm {
20  StringRef DebugType;
21  SmallSet<DebugLoc, 4> LostDebugLocs;
22  SmallPtrSet<MachineInstr *, 4> PotentialMIsForDebugLocs;
23  unsigned NumLostDebugLocs = 0;
24 
25 public:
26  LostDebugLocObserver(StringRef DebugType) : DebugType(DebugType) {}
27 
28  unsigned getNumLostDebugLocs() const { return NumLostDebugLocs; }
29 
30  /// Call this to indicate that it's a good point to assess whether locations
31  /// have been lost. Typically this will be when a logical change has been
32  /// completed such as the caller has finished replacing some instructions with
33  /// alternatives. When CheckDebugLocs is true, the locations will be checked
34  /// to see if any have been lost since the last checkpoint. When
35  /// CheckDebugLocs is false, it will just reset ready for the next checkpoint
36  /// without checking anything. This can be helpful to limit the detection to
37  /// easy-to-fix portions of an algorithm before allowing more difficult ones.
38  void checkpoint(bool CheckDebugLocs = true);
39 
40  void createdInstr(MachineInstr &MI) override;
41  void erasingInstr(MachineInstr &MI) override;
42  void changingInstr(MachineInstr &MI) override;
43  void changedInstr(MachineInstr &MI) override;
44 
45 private:
46  void analyzeDebugLocations();
47 };
48 
49 } // namespace llvm
50 #endif // LLVM_CODEGEN_GLOBALISEL_LOSTDEBUGLOCOBSERVER_H
MI
IRTranslator LLVM IR MI
Definition: IRTranslator.cpp:103
llvm
---------------------— PointerInfo ------------------------------------—
Definition: AllocatorList.h:23
llvm::LostDebugLocObserver
Definition: LostDebugLocObserver.h:19
llvm::SmallSet
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:134
llvm::SmallPtrSet
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:449
llvm::LostDebugLocObserver::LostDebugLocObserver
LostDebugLocObserver(StringRef DebugType)
Definition: LostDebugLocObserver.h:26
llvm::LostDebugLocObserver::changedInstr
void changedInstr(MachineInstr &MI) override
This instruction was mutated in some way.
Definition: LostDebugLocObserver.cpp:111
llvm::LostDebugLocObserver::checkpoint
void checkpoint(bool CheckDebugLocs=true)
Call this to indicate that it's a good point to assess whether locations have been lost.
Definition: LostDebugLocObserver.cpp:70
llvm::LostDebugLocObserver::getNumLostDebugLocs
unsigned getNumLostDebugLocs() const
Definition: LostDebugLocObserver.h:28
llvm::MachineInstr
Representation of each machine instruction.
Definition: MachineInstr.h:64
llvm::StringRef
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:58
llvm::GISelChangeObserver
Abstract class that contains various methods for clients to notify about changes.
Definition: GISelChangeObserver.h:29
llvm::LostDebugLocObserver::changingInstr
void changingInstr(MachineInstr &MI) override
This instruction is about to be mutated in some way.
Definition: LostDebugLocObserver.cpp:102
llvm::LostDebugLocObserver::createdInstr
void createdInstr(MachineInstr &MI) override
An instruction has been created and inserted into the function.
Definition: LostDebugLocObserver.cpp:77
llvm::LostDebugLocObserver::erasingInstr
void erasingInstr(MachineInstr &MI) override
An instruction is about to be erased.
Definition: LostDebugLocObserver.cpp:93
GISelChangeObserver.h
SmallSet.h