|
16 | 16 | #ifndef LLVM_IR_DEBUGINFO_H
|
17 | 17 | #define LLVM_IR_DEBUGINFO_H
|
18 | 18 |
|
| 19 | +#include "llvm/ADT/DenseMapInfo.h" |
19 | 20 | #include "llvm/ADT/STLExtras.h"
|
| 21 | +#include "llvm/ADT/SetVector.h" |
20 | 22 | #include "llvm/ADT/SmallPtrSet.h"
|
21 | 23 | #include "llvm/ADT/SmallSet.h"
|
22 | 24 | #include "llvm/ADT/SmallVector.h"
|
@@ -259,11 +261,35 @@ struct VarRecord {
|
259 | 261 | }
|
260 | 262 | };
|
261 | 263 |
|
| 264 | +} // namespace at |
| 265 | + |
| 266 | +template <> struct DenseMapInfo<at::VarRecord> { |
| 267 | + static inline at::VarRecord getEmptyKey() { |
| 268 | + return at::VarRecord(DenseMapInfo<DILocalVariable *>::getEmptyKey(), |
| 269 | + DenseMapInfo<DILocation *>::getEmptyKey()); |
| 270 | + } |
| 271 | + |
| 272 | + static inline at::VarRecord getTombstoneKey() { |
| 273 | + return at::VarRecord(DenseMapInfo<DILocalVariable *>::getTombstoneKey(), |
| 274 | + DenseMapInfo<DILocation *>::getTombstoneKey()); |
| 275 | + } |
| 276 | + |
| 277 | + static unsigned getHashValue(const at::VarRecord &Var) { |
| 278 | + return hash_combine(Var.Var, Var.DL); |
| 279 | + } |
| 280 | + |
| 281 | + static bool isEqual(const at::VarRecord &A, const at::VarRecord &B) { |
| 282 | + return A == B; |
| 283 | + } |
| 284 | +}; |
| 285 | + |
| 286 | +namespace at { |
262 | 287 | /// Map of backing storage to a set of variables that are stored to it.
|
263 | 288 | /// TODO: Backing storage shouldn't be limited to allocas only. Some local
|
264 | 289 | /// variables have their storage allocated by the calling function (addresses
|
265 | 290 | /// passed in with sret & byval parameters).
|
266 |
| -using StorageToVarsMap = DenseMap<const AllocaInst *, SmallSet<VarRecord, 2>>; |
| 291 | +using StorageToVarsMap = |
| 292 | + DenseMap<const AllocaInst *, SmallSetVector<VarRecord, 2>>; |
267 | 293 |
|
268 | 294 | /// Track assignments to \p Vars between \p Start and \p End.
|
269 | 295 |
|
@@ -314,6 +340,7 @@ class AssignmentTrackingPass : public PassInfoMixin<AssignmentTrackingPass> {
|
314 | 340 |
|
315 | 341 | /// Return true if assignment tracking is enabled for module \p M.
|
316 | 342 | bool isAssignmentTrackingEnabled(const Module &M);
|
| 343 | + |
317 | 344 | } // end namespace llvm
|
318 | 345 |
|
319 | 346 | #endif // LLVM_IR_DEBUGINFO_H
|
0 commit comments