@@ -23,14 +23,23 @@ namespace swift {
2323
2424class AllocationInst ;
2525
26+ // / Holds common debug information about local variables and function
27+ // / arguments that are needed by DebugValueInst, AllocStackInst,
28+ // / and AllocBoxInst.
29+ struct SILDebugVariable ;
30+ inline llvm::hash_code hash_value (const SILDebugVariable &P);
31+
2632// / Holds common debug information about local variables and function
2733// / arguments that are needed by DebugValueInst, AllocStackInst,
2834// / and AllocBoxInst.
2935struct SILDebugVariable {
36+ friend llvm::hash_code hash_value (const SILDebugVariable &P);
37+
3038 StringRef Name;
3139 unsigned ArgNo : 16 ;
3240 unsigned Constant : 1 ;
3341 unsigned Implicit : 1 ;
42+ unsigned isDenseMapSingleton : 2 ;
3443 Optional<SILType> Type;
3544 Optional<SILLocation> Loc;
3645 const SILDebugScope *Scope;
@@ -40,26 +49,41 @@ struct SILDebugVariable {
4049 SILDebugVariable (const SILDebugVariable &) = default ;
4150 SILDebugVariable &operator =(const SILDebugVariable &) = default ;
4251
52+ enum class IsDenseMapSingleton { No, IsEmpty, IsTombstone };
53+ SILDebugVariable (IsDenseMapSingleton inputIsDenseMapSingleton)
54+ : SILDebugVariable() {
55+ assert (inputIsDenseMapSingleton != IsDenseMapSingleton::No &&
56+ " Should only pass IsEmpty or IsTombstone" );
57+ isDenseMapSingleton = unsigned (inputIsDenseMapSingleton);
58+ }
59+
4360 SILDebugVariable ()
44- : ArgNo(0 ), Constant(false ), Implicit(false ), Scope(nullptr ) {}
61+ : ArgNo(0 ), Constant(false ), Implicit(false ), isDenseMapSingleton(0 ),
62+ Scope (nullptr ) {}
4563 SILDebugVariable (bool Constant, uint16_t ArgNo)
46- : ArgNo(ArgNo), Constant(Constant), Implicit(false ), Scope(nullptr ) {}
64+ : ArgNo(ArgNo), Constant(Constant), Implicit(false ),
65+ isDenseMapSingleton(0 ), Scope(nullptr ) {}
4766 SILDebugVariable (StringRef Name, bool Constant, unsigned ArgNo,
4867 bool IsImplicit = false , Optional<SILType> AuxType = {},
4968 Optional<SILLocation> DeclLoc = {},
5069 const SILDebugScope *DeclScope = nullptr ,
5170 llvm::ArrayRef<SILDIExprElement> ExprElements = {})
5271 : Name(Name), ArgNo(ArgNo), Constant(Constant), Implicit(IsImplicit),
53- Type (AuxType), Loc(DeclLoc), Scope(DeclScope), DIExpr(ExprElements) {}
72+ isDenseMapSingleton(0 ), Type(AuxType), Loc(DeclLoc), Scope(DeclScope),
73+ DIExpr(ExprElements) {}
5474
5575 // / Created from either AllocStack or AllocBox instruction
5676 static Optional<SILDebugVariable>
5777 createFromAllocation (const AllocationInst *AI);
5878
59- bool operator ==(const SILDebugVariable &V) {
79+ // We're not comparing DIExpr here because strictly speaking,
80+ // DIExpr is not part of the debug variable. We simply piggyback
81+ // it in this class so that's it's easier to carry DIExpr around.
82+ bool operator ==(const SILDebugVariable &V) const {
6083 return ArgNo == V.ArgNo && Constant == V.Constant && Name == V.Name &&
6184 Implicit == V.Implicit && Type == V.Type && Loc == V.Loc &&
62- Scope == V.Scope && DIExpr == V.DIExpr ;
85+ Scope == V.Scope && isDenseMapSingleton == V.isDenseMapSingleton &&
86+ DIExpr == V.DIExpr ;
6387 }
6488
6589 SILDebugVariable withoutDIExpr () const {
@@ -73,6 +97,13 @@ struct SILDebugVariable {
7397 bool isVar () const { return Name.size () && !Constant; }
7498};
7599
100+ // / Returns the hashcode for the new projection path.
101+ inline llvm::hash_code hash_value (const SILDebugVariable &P) {
102+ return llvm::hash_combine (P.ArgNo , P.Constant , P.Name , P.Implicit ,
103+ P.isDenseMapSingleton , P.Type , P.Loc , P.Scope ,
104+ P.DIExpr );
105+ }
106+
76107} // namespace swift
77108
78109#endif
0 commit comments