Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
14 | pmbaty | 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" |
||
16 | #include "llvm/CodeGen/GlobalISel/GISelChangeObserver.h" |
||
17 | |||
18 | namespace llvm { |
||
19 | class LostDebugLocObserver : public GISelChangeObserver { |
||
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 |