LLVM: lib/Transforms/Utils/AddDiscriminators.cpp Source File (original) (raw)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
71#include
72
73using namespace llvm;
75
76#define DEBUG_TYPE "add-discriminators"
77
78
79
80
82 "no-discriminators", cl::init(false),
83 cl::desc("Disable generation of discriminator information."));
84
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
141
142
143
145 return false;
146
147
150
152
153 using Location = std::pair<StringRef, unsigned>;
158
159 LocationBBMap LBM;
160 LocationDiscriminatorMap LDM;
161
162
163
164
167
168
169
170
171
172
174 continue;
176 if (!DIL)
177 continue;
178 Location L = std::make_pair(DIL->getFilename(), DIL->getLine());
179 auto &BBMap = LBM[L];
180 auto R = BBMap.insert(&B);
181 if (BBMap.size() == 1)
182 continue;
183
184
185
186
187 unsigned Discriminator = R.second ? ++LDM[L] : LDM[L];
189 if (!NewDIL) {
190 LLVM_DEBUG(dbgs() << "Could not encode discriminator: "
191 << DIL->getFilename() << ":" << DIL->getLine() << ":"
192 << DIL->getColumn() << ":" << Discriminator << " "
193 << I << "\n");
194 } else {
195 I.setDebugLoc(*NewDIL);
196 LLVM_DEBUG(dbgs() << DIL->getFilename() << ":" << DIL->getLine() << ":"
197 << DIL->getColumn() << ":" << Discriminator << " " << I
198 << "\n");
199 }
201 }
202 }
203
204
205
206
207
209 LocationSet CallLocations;
211
212
213
214
216 continue;
217
218 DILocation *CurrentDIL = I.getDebugLoc();
219 if (!CurrentDIL)
220 continue;
221 Location L =
222 std::make_pair(CurrentDIL->getFilename(), CurrentDIL->getLine());
223 if (!CallLocations.insert(L).second) {
224 unsigned Discriminator = ++LDM[L];
226 if (!NewDIL) {
228 << "Could not encode discriminator: "
229 << CurrentDIL->getFilename() << ":"
230 << CurrentDIL->getLine() << ":" << CurrentDIL->getColumn()
231 << ":" << Discriminator << " " << I << "\n");
232 } else {
233 I.setDebugLoc(*NewDIL);
235 }
236 }
237 }
238 }
240}
241
static cl::opt< bool > NoDiscriminators("no-discriminators", cl::init(false), cl::desc("Disable generation of discriminator information."))
static bool addDiscriminators(Function &F)
Assign DWARF discriminators.
Definition AddDiscriminators.cpp:140
static bool shouldHaveDiscriminator(const Instruction *I)
Definition AddDiscriminators.cpp:85
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file defines the DenseMap class.
This file defines the DenseSet and SmallDenseSet classes.
This header defines various interfaces for pass management in LLVM.
This file provides the utility functions for the sampled PGO loader base implementation.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
Definition AddDiscriminators.cpp:242
LLVM Basic Block Representation.
std::optional< const DILocation * > cloneWithBaseDiscriminator(unsigned BD) const
Returns a new DILocation with updated base discriminator BD.
Implements a dense probed hash-table based set.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses none()
Convenience factory function for the empty preserved set.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
initializer< Ty > init(const Ty &Val)
void createFSDiscriminatorVariable(Module *M)
Create a global variable to flag FSDiscriminators are used.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI cl::opt< bool > EnableFSDiscriminator
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
bool isa(const From &Val)
isa - Return true if the parameter to the template is an instance of one of the template type argu...
AnalysisManager< Function > FunctionAnalysisManager
Convenience typedef for the Function analysis manager.