LLVM: lib/CodeGen/GlobalISel/LostDebugLocObserver.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
14
15using namespace llvm;
16
17#define LOC_DEBUG(X) DEBUG_WITH_TYPE(DebugType.str().c_str(), X)
18
19void LostDebugLocObserver::analyzeDebugLocations() {
20 if (LostDebugLocs.empty()) {
21 LOC_DEBUG(dbgs() << ".. No debug info was present\n");
22 return;
23 }
24 if (PotentialMIsForDebugLocs.empty()) {
26 dbgs() << ".. No instructions to carry debug info (dead code?)\n");
27 return;
28 }
29
30 LOC_DEBUG(dbgs() << ".. Searching " << PotentialMIsForDebugLocs.size()
31 << " instrs for " << LostDebugLocs.size() << " locations\n");
34 if (->getDebugLoc())
35 continue;
36
37
38 if (MI->getDebugLoc().getLine() == 0) {
40 dbgs() << ".. Assuming line-0 location covers remainder (if any)\n");
41 return;
42 }
43 if (LostDebugLocs.erase(MI->getDebugLoc())) {
44 LOC_DEBUG(dbgs() << ".. .. found " << MI->getDebugLoc() << " in " << *MI);
46 continue;
47 }
48 }
49 if (LostDebugLocs.empty())
50 return;
51
52 NumLostDebugLocs += LostDebugLocs.size();
54 dbgs() << ".. Lost locations:\n";
55 for (const DebugLoc &Loc : LostDebugLocs) {
56 dbgs() << ".. .. ";
58 dbgs() << "\n";
59 }
60 dbgs() << ".. MIs with matched locations:\n";
62 if (PotentialMIsForDebugLocs.erase(MI))
64 dbgs() << ".. Remaining MIs with unmatched/no locations:\n";
65 for (const MachineInstr *MI : PotentialMIsForDebugLocs)
67 });
68}
69
71 if (CheckDebugLocs)
72 analyzeDebugLocations();
73 PotentialMIsForDebugLocs.clear();
74 LostDebugLocs.clear();
75}
76
78 PotentialMIsForDebugLocs.insert(&MI);
79}
80
82 switch (Opcode) {
83 default:
84 return false;
85 case TargetOpcode::G_CONSTANT:
86 case TargetOpcode::G_FCONSTANT:
87 case TargetOpcode::G_IMPLICIT_DEF:
88 case TargetOpcode::G_GLOBAL_VALUE:
89 return true;
90 }
91}
92
95 return;
96
97 PotentialMIsForDebugLocs.erase(&MI);
98 if (MI.getDebugLoc())
99 LostDebugLocs.insert(MI.getDebugLoc());
100}
101
104 return;
105
106 PotentialMIsForDebugLocs.erase(&MI);
107 if (MI.getDebugLoc())
108 LostDebugLocs.insert(MI.getDebugLoc());
109}
110
112 PotentialMIsForDebugLocs.insert(&MI);
113}
#define LOC_DEBUG(X)
Definition LostDebugLocObserver.cpp:17
static bool irTranslatorNeverAddsLocations(unsigned Opcode)
Definition LostDebugLocObserver.cpp:81
Tracks DebugLocs between checkpoints and verifies that they are transferred.
void createdInstr(MachineInstr &MI) override
An instruction has been created and inserted into the function.
Definition LostDebugLocObserver.cpp:77
void changedInstr(MachineInstr &MI) override
This instruction was mutated in some way.
Definition LostDebugLocObserver.cpp:111
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
void erasingInstr(MachineInstr &MI) override
An instruction is about to be erased.
Definition LostDebugLocObserver.cpp:93
void changingInstr(MachineInstr &MI) override
This instruction is about to be mutated in some way.
Definition LostDebugLocObserver.cpp:102
Representation of each machine instruction.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.