LLVM 22.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"
18
19namespace llvm {
21 StringRef DebugType;
22 SmallSet<DebugLoc, 4> LostDebugLocs;
23 SmallPtrSet<MachineInstr *, 4> PotentialMIsForDebugLocs;
24 unsigned NumLostDebugLocs = 0;
25
26public:
27 LostDebugLocObserver(StringRef DebugType) : DebugType(DebugType) {}
28
29 unsigned getNumLostDebugLocs() const { return NumLostDebugLocs; }
30
31 /// Call this to indicate that it's a good point to assess whether locations
32 /// have been lost. Typically this will be when a logical change has been
33 /// completed such as the caller has finished replacing some instructions with
34 /// alternatives. When CheckDebugLocs is true, the locations will be checked
35 /// to see if any have been lost since the last checkpoint. When
36 /// CheckDebugLocs is false, it will just reset ready for the next checkpoint
37 /// without checking anything. This can be helpful to limit the detection to
38 /// easy-to-fix portions of an algorithm before allowing more difficult ones.
39 void checkpoint(bool CheckDebugLocs = true);
40
41 void createdInstr(MachineInstr &MI) override;
42 void erasingInstr(MachineInstr &MI) override;
43 void changingInstr(MachineInstr &MI) override;
44 void changedInstr(MachineInstr &MI) override;
45
46private:
47 void analyzeDebugLocations();
48};
49
50} // namespace llvm
51#endif // LLVM_CODEGEN_GLOBALISEL_LOSTDEBUGLOCOBSERVER_H
#define LLVM_ABI
Definition Compiler.h:213
This contains common code to allow clients to notify changes to machine instr.
IRTranslator LLVM IR MI
This file defines the SmallSet class.
Abstract class that contains various methods for clients to notify about changes.
LostDebugLocObserver(StringRef DebugType)
Representation of each machine instruction.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition SmallSet.h:133
StringRef - Represent a constant reference to a string, i.e.
Definition StringRef.h:55
This is an optimization pass for GlobalISel generic memory operations.