@@ -323,13 +323,17 @@ class SILInstruction : public llvm::ilist_node<SILInstruction> {
323
323
324
324
// / A backreference to the containing basic block. This is maintained by
325
325
// / ilist_traits<SILInstruction>.
326
- SILBasicBlock *ParentBB;
326
+ SILBasicBlock *ParentBB = nullptr ;
327
327
328
- // / This instruction's containing lexical scope and source location
329
- // / used for debug info and diagnostics.
330
- SILDebugLocation Location;
328
+ // / This instruction's containing lexical scope for debug info.
329
+ const SILDebugScope *debugScope = nullptr ;
330
+
331
+ // / This instructions source location for diagnostics and debug info.
332
+ // /
333
+ // / To reduce space, this is only the storage of the SILLocation. The
334
+ // / location's kindAndFlags is stored in the SILNode inline bitfields.
335
+ SILLocation::Storage locationStorage;
331
336
332
- SILInstruction () = delete ;
333
337
void operator =(const SILInstruction &) = delete ;
334
338
void operator delete (void *Ptr, size_t ) = delete ;
335
339
@@ -360,8 +364,7 @@ class SILInstruction : public llvm::ilist_node<SILInstruction> {
360
364
SILInstructionResultArray getResultsImpl () const ;
361
365
362
366
protected:
363
- SILInstruction (SILDebugLocation DebugLoc) :
364
- ParentBB (nullptr ), Location(DebugLoc) {
367
+ SILInstruction () {
365
368
NumCreatedInstructions++;
366
369
}
367
370
@@ -423,14 +426,25 @@ class SILInstruction : public llvm::ilist_node<SILInstruction> {
423
426
SILModule &getModule () const ;
424
427
425
428
// / This instruction's source location (AST node).
426
- SILLocation getLoc () const ;
427
- const SILDebugScope *getDebugScope () const ;
428
- SILDebugLocation getDebugLocation () const { return Location; }
429
+ SILLocation getLoc () const {
430
+ return SILLocation (locationStorage,
431
+ asSILNode ()->Bits .SILInstruction .LocationKindAndFlags );
432
+ }
433
+ const SILDebugScope *getDebugScope () const { return debugScope; }
434
+ SILDebugLocation getDebugLocation () const {
435
+ return SILDebugLocation (getLoc (), debugScope);
436
+ }
429
437
430
438
// / Sets the debug location.
431
439
// / Note: Usually it should not be needed to use this function as the location
432
440
// / is already set in when creating an instruction.
433
- void setDebugLocation (SILDebugLocation Loc) { Location = Loc; }
441
+ void setDebugLocation (SILDebugLocation debugLoc) {
442
+ debugScope = debugLoc.getScope ();
443
+ SILLocation loc = debugLoc.getLocation ();
444
+ asSILNode ()->Bits .SILInstruction .LocationKindAndFlags =
445
+ loc.kindAndFlags .packedKindAndFlags ;
446
+ locationStorage = loc.storage ;
447
+ }
434
448
435
449
// / This method unlinks 'self' from the containing basic block and deletes it.
436
450
void eraseFromParent ();
@@ -758,7 +772,9 @@ class NonSingleValueInstruction : public SILInstruction, public SILNode {
758
772
friend struct SILNodeOffsetChecker ;
759
773
public:
760
774
NonSingleValueInstruction (SILInstructionKind kind, SILDebugLocation loc)
761
- : SILInstruction(loc), SILNode((SILNodeKind)kind) {}
775
+ : SILInstruction(), SILNode((SILNodeKind)kind) {
776
+ setDebugLocation (loc);
777
+ }
762
778
763
779
using SILInstruction::operator new ;
764
780
using SILInstruction::dumpInContext;
@@ -929,8 +945,9 @@ class SingleValueInstruction : public SILInstruction, public ValueBase {
929
945
public:
930
946
SingleValueInstruction (SILInstructionKind kind, SILDebugLocation loc,
931
947
SILType type)
932
- : SILInstruction(loc),
933
- ValueBase (ValueKind(kind), type) {}
948
+ : SILInstruction(), ValueBase(ValueKind(kind), type) {
949
+ setDebugLocation (loc);
950
+ }
934
951
935
952
using SILInstruction::operator new ;
936
953
using SILInstruction::dumpInContext;
0 commit comments