LLVM 18.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
18namespace llvm {
20 StringRef DebugType;
21 SmallSet<DebugLoc, 4> LostDebugLocs;
22 SmallPtrSet<MachineInstr *, 4> PotentialMIsForDebugLocs;
23 unsigned NumLostDebugLocs = 0;
24
25public:
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
45private:
46 void analyzeDebugLocations();
47};
48
49} // namespace llvm
50#endif // LLVM_CODEGEN_GLOBALISEL_LOSTDEBUGLOCOBSERVER_H
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.
void createdInstr(MachineInstr &MI) override
An instruction has been created and inserted into the function.
void changedInstr(MachineInstr &MI) override
This instruction was mutated in some way.
void checkpoint(bool CheckDebugLocs=true)
Call this to indicate that it's a good point to assess whether locations have been lost.
void erasingInstr(MachineInstr &MI) override
An instruction is about to be erased.
void changingInstr(MachineInstr &MI) override
This instruction is about to be mutated in some way.
LostDebugLocObserver(StringRef DebugType)
unsigned getNumLostDebugLocs() const
Representation of each machine instruction.
Definition: MachineInstr.h:68
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
Definition: SmallPtrSet.h:451
SmallSet - This maintains a set of unique values, optimizing for the case when the set is small (less...
Definition: SmallSet.h:135
StringRef - Represent a constant reference to a string, i.e.
Definition: StringRef.h:50
This is an optimization pass for GlobalISel generic memory operations.
Definition: AddressRanges.h:18