@@ -126,6 +126,9 @@ class alignas(8) SILNode :
126126 enum { NumAllocRefTailTypesBits = 4 };
127127 enum { NumMarkDependenceKindBits = 2 };
128128
129+ enum { numCustomBits = 20 };
130+ enum { maxBitfieldID = std::numeric_limits<uint64_t >::max () >> numCustomBits };
131+
129132protected:
130133 friend class SILInstruction ;
131134 template <class , class > friend class SILBitfield ;
@@ -135,11 +138,7 @@ class alignas(8) SILNode :
135138
136139 uint8_t kind;
137140
138- // Used by `NodeBitfield`.
139- enum { numCustomBits = 8 };
140-
141- // Used by `NodeBitfield`.
142- uint8_t customBits;
141+ bool deleted = false ;
143142
144143 // Part of SILInstruction's debug location. Together with
145144 // `SILInstruction::locationStorage` this forms the SILLocation.
@@ -364,6 +363,9 @@ class alignas(8) SILNode :
364363
365364 // ===---------------------- end of shared fields ------------------------===//
366365
366+ // Used by `NodeBitfield`.
367+ uint64_t customBits : numCustomBits;
368+
367369 // / The NodeBitfield ID of the last initialized bitfield in `customBits`.
368370 // / Example:
369371 // /
@@ -377,20 +379,19 @@ class alignas(8) SILNode :
377379 // / -> AAA, BB and C are initialized,
378380 // / DD and EEE are uninitialized
379381 // /
380- // / If the ID is negative, it means that the node (in case it's an instruction)
381- // / is deleted, i.e. it does not belong to the function anymore. Conceptually
382- // / this results in setting all bitfields to zero, which e.g. "removes" the
383- // / node from all NodeSets.
382+ // / The size of lastInitializedBitfieldID should be more than 32 bits to
383+ // / absolutely avoid an overflow.
384384 // /
385385 // / See also: SILBitfield::bitfieldID, SILFunction::currentBitfieldID.
386- int64_t lastInitializedBitfieldID = 0 ;
386+ uint64_t lastInitializedBitfieldID : ( 64 - numCustomBits) ;
387387
388388private:
389389 SwiftMetatype getSILNodeMetatype (SILNodeKind kind);
390390
391391protected:
392392 SILNode (SILNodeKind kind) : SwiftObjectHeader (getSILNodeMetatype (kind)),
393- kind ((uint8_t )kind) {
393+ kind ((uint8_t )kind),
394+ customBits (0 ), lastInitializedBitfieldID (0 ) {
394395 _sharedUInt8_private.opaque = 0 ;
395396 _sharedUInt32_private.opaque = 0 ;
396397 }
@@ -442,11 +443,8 @@ class alignas(8) SILNode :
442443 lastInitializedBitfieldID = 0 ;
443444 }
444445
445- void markAsDeleted () {
446- lastInitializedBitfieldID = -1 ;
447- }
448-
449- bool isMarkedAsDeleted () const { return lastInitializedBitfieldID < 0 ; }
446+ void markAsDeleted () { deleted = true ; }
447+ bool isMarkedAsDeleted () const { return deleted; }
450448
451449 static SILNode *instAsNode (SILInstruction *inst);
452450 static const SILNode *instAsNode (const SILInstruction *inst);
0 commit comments