@@ -1806,6 +1806,50 @@ class TailAllocatedDebugVariable {
1806
1806
static_assert (sizeof (TailAllocatedDebugVariable) == 4,
1807
1807
"SILNode inline bitfield needs updating");
1808
1808
1809
+ // / Used for keeping track of advanced / supplement debug variable info
1810
+ // / stored in trailing objects space inside debug instructions (e.g.
1811
+ // / debug_value)
1812
+ class SILDebugVariableSupplement {
1813
+ protected:
1814
+ enum SourceLocKind : unsigned { SLK_Loc = 0b01 , SLK_Scope = 0b10 };
1815
+
1816
+ unsigned NumDIExprOperands : 8 ;
1817
+
1818
+ unsigned HasAuxDebugVariableType : 1 ;
1819
+
1820
+ unsigned AuxVariableSourceLoc : 2 ;
1821
+
1822
+ SILDebugVariableSupplement (unsigned NumDIExprOps, bool AuxType, bool AuxLoc,
1823
+ bool AuxScope)
1824
+ : NumDIExprOperands(NumDIExprOps), HasAuxDebugVariableType(AuxType),
1825
+ AuxVariableSourceLoc ((AuxLoc ? SLK_Loc : 0 ) |
1826
+ (AuxScope ? SLK_Scope : 0 )) {}
1827
+ };
1828
+
1829
+ #define SIL_DEBUG_VAR_SUPPLEMENT_TRAILING_OBJS_IMPL () \
1830
+ inline bool hasAuxDebugLocation () const { \
1831
+ return AuxVariableSourceLoc & SLK_Loc; \
1832
+ } \
1833
+ inline bool hasAuxDebugScope () const { \
1834
+ return AuxVariableSourceLoc & SLK_Scope; \
1835
+ } \
1836
+ \
1837
+ size_t numTrailingObjects (OverloadToken<SILType>) const { \
1838
+ return HasAuxDebugVariableType ? 1 : 0 ; \
1839
+ } \
1840
+ \
1841
+ size_t numTrailingObjects (OverloadToken<SILLocation>) const { \
1842
+ return hasAuxDebugLocation () ? 1 : 0 ; \
1843
+ } \
1844
+ \
1845
+ size_t numTrailingObjects (OverloadToken<const SILDebugScope *>) const { \
1846
+ return hasAuxDebugScope () ? 1 : 0 ; \
1847
+ } \
1848
+ \
1849
+ size_t numTrailingObjects (OverloadToken<SILDIExprElement>) const { \
1850
+ return NumDIExprOperands; \
1851
+ }
1852
+
1809
1853
// ===----------------------------------------------------------------------===//
1810
1854
// Allocation Instructions
1811
1855
// ===----------------------------------------------------------------------===//
@@ -1833,7 +1877,10 @@ class DeallocStackInst;
1833
1877
class AllocStackInst final
1834
1878
: public InstructionBase<SILInstructionKind::AllocStackInst,
1835
1879
AllocationInst>,
1836
- private llvm::TrailingObjects<AllocStackInst, Operand, char > {
1880
+ private SILDebugVariableSupplement,
1881
+ private llvm::TrailingObjects<AllocStackInst, SILType, SILLocation,
1882
+ const SILDebugScope *, SILDIExprElement,
1883
+ Operand, char > {
1837
1884
friend TrailingObjects;
1838
1885
friend SILBuilder;
1839
1886
@@ -1849,6 +1896,8 @@ class AllocStackInst final
1849
1896
Optional<SILDebugVariable> Var,
1850
1897
bool hasDynamicLifetime);
1851
1898
1899
+ SIL_DEBUG_VAR_SUPPLEMENT_TRAILING_OBJS_IMPL ()
1900
+
1852
1901
size_t numTrailingObjects (OverloadToken<Operand>) const {
1853
1902
return SILNode::Bits.AllocStackInst .NumOperands ;
1854
1903
}
@@ -1878,9 +1927,24 @@ class AllocStackInst final
1878
1927
1879
1928
// / Return the debug variable information attached to this instruction.
1880
1929
Optional<SILDebugVariable> getVarInfo () const {
1930
+ Optional<SILType> AuxVarType;
1931
+ Optional<SILLocation> VarDeclLoc;
1932
+ const SILDebugScope *VarDeclScope = nullptr ;
1933
+ if (HasAuxDebugVariableType)
1934
+ AuxVarType = *getTrailingObjects<SILType>();
1935
+
1936
+ if (hasAuxDebugLocation ())
1937
+ VarDeclLoc = *getTrailingObjects<SILLocation>();
1938
+ if (hasAuxDebugScope ())
1939
+ VarDeclScope = *getTrailingObjects<const SILDebugScope *>();
1940
+
1941
+ llvm::ArrayRef<SILDIExprElement> DIExprElements (
1942
+ getTrailingObjects<SILDIExprElement>(), NumDIExprOperands);
1943
+
1881
1944
auto RawValue = SILNode::Bits.AllocStackInst .VarInfo ;
1882
1945
auto VI = TailAllocatedDebugVariable (RawValue);
1883
- return VI.get (getDecl (), getTrailingObjects<char >());
1946
+ return VI.get (getDecl (), getTrailingObjects<char >(), AuxVarType, VarDeclLoc,
1947
+ VarDeclScope, DIExprElements);
1884
1948
};
1885
1949
void setArgNo (unsigned N) {
1886
1950
auto RawValue = SILNode::Bits.AllocStackInst .VarInfo ;
@@ -4560,29 +4624,18 @@ class MarkFunctionEscapeInst final
4560
4624
}
4561
4625
};
4562
4626
4563
- // / Simple bitmasks that represent whether a SIL instruction
4564
- // / or debug variable has SILLocation, DebugScope, or both of them
4565
- // / attached.
4566
- struct SILSourceLocKind {
4567
- static constexpr unsigned Loc = 0b01 ;
4568
- static constexpr unsigned Scope = 0b10 ;
4569
- };
4570
-
4571
4627
// / Define the start or update to a symbolic variable value (for loadable
4572
4628
// / types).
4573
4629
class DebugValueInst final
4574
4630
: public UnaryInstructionBase<SILInstructionKind::DebugValueInst,
4575
4631
NonValueInstruction>,
4632
+ private SILDebugVariableSupplement,
4576
4633
private llvm::TrailingObjects<DebugValueInst, SILType, SILLocation,
4577
4634
const SILDebugScope *, SILDIExprElement,
4578
4635
char > {
4579
4636
friend TrailingObjects;
4580
4637
friend SILBuilder;
4581
4638
4582
- unsigned NumDIExprOperands;
4583
- bool HasAuxDebugVariableType;
4584
- unsigned AuxVariableSourceLoc : 2 ;
4585
-
4586
4639
TailAllocatedDebugVariable VarInfo;
4587
4640
4588
4641
DebugValueInst (SILDebugLocation DebugLoc, SILValue Operand,
@@ -4591,28 +4644,7 @@ class DebugValueInst final
4591
4644
SILModule &M, SILDebugVariable Var,
4592
4645
bool poisonRefs);
4593
4646
4594
- inline bool hasAuxDebugLocation () const {
4595
- return AuxVariableSourceLoc & SILSourceLocKind::Loc;
4596
- }
4597
- inline bool hasAuxDebugScope () const {
4598
- return AuxVariableSourceLoc & SILSourceLocKind::Scope;
4599
- }
4600
-
4601
- size_t numTrailingObjects (OverloadToken<SILType>) const {
4602
- return HasAuxDebugVariableType ? 1 : 0 ;
4603
- }
4604
-
4605
- size_t numTrailingObjects (OverloadToken<SILLocation>) const {
4606
- return hasAuxDebugLocation () ? 1 : 0 ;
4607
- }
4608
-
4609
- size_t numTrailingObjects (OverloadToken<const SILDebugScope *>) const {
4610
- return hasAuxDebugScope () ? 1 : 0 ;
4611
- }
4612
-
4613
- size_t numTrailingObjects (OverloadToken<SILDIExprElement>) const {
4614
- return NumDIExprOperands;
4615
- }
4647
+ SIL_DEBUG_VAR_SUPPLEMENT_TRAILING_OBJS_IMPL ()
4616
4648
4617
4649
size_t numTrailingObjects (OverloadToken<char >) const { return 1 ; }
4618
4650
@@ -4622,7 +4654,6 @@ class DebugValueInst final
4622
4654
VarDecl *getDecl () const ;
4623
4655
// / Return the debug variable information attached to this instruction.
4624
4656
Optional<SILDebugVariable> getVarInfo () const {
4625
- ;
4626
4657
Optional<SILType> AuxVarType;
4627
4658
Optional<SILLocation> VarDeclLoc;
4628
4659
const SILDebugScope *VarDeclScope = nullptr ;
@@ -4662,16 +4693,13 @@ class DebugValueInst final
4662
4693
class DebugValueAddrInst final
4663
4694
: public UnaryInstructionBase<SILInstructionKind::DebugValueAddrInst,
4664
4695
NonValueInstruction>,
4696
+ private SILDebugVariableSupplement,
4665
4697
private llvm::TrailingObjects<DebugValueAddrInst, SILType, SILLocation,
4666
4698
const SILDebugScope *, SILDIExprElement,
4667
4699
char > {
4668
4700
friend TrailingObjects;
4669
4701
friend SILBuilder;
4670
4702
4671
- unsigned NumDIExprOperands;
4672
- bool HasAuxDebugVariableType;
4673
- unsigned AuxVariableSourceLoc : 2 ;
4674
-
4675
4703
TailAllocatedDebugVariable VarInfo;
4676
4704
4677
4705
DebugValueAddrInst (SILDebugLocation DebugLoc, SILValue Operand,
@@ -4680,28 +4708,7 @@ class DebugValueAddrInst final
4680
4708
SILValue Operand, SILModule &M,
4681
4709
SILDebugVariable Var);
4682
4710
4683
- inline bool hasAuxDebugLocation () const {
4684
- return AuxVariableSourceLoc & SILSourceLocKind::Loc;
4685
- }
4686
- inline bool hasAuxDebugScope () const {
4687
- return AuxVariableSourceLoc & SILSourceLocKind::Scope;
4688
- }
4689
-
4690
- size_t numTrailingObjects (OverloadToken<SILType>) const {
4691
- return HasAuxDebugVariableType ? 1 : 0 ;
4692
- }
4693
-
4694
- size_t numTrailingObjects (OverloadToken<SILLocation>) const {
4695
- return hasAuxDebugLocation () ? 1 : 0 ;
4696
- }
4697
-
4698
- size_t numTrailingObjects (OverloadToken<const SILDebugScope *>) const {
4699
- return hasAuxDebugScope () ? 1 : 0 ;
4700
- }
4701
-
4702
- size_t numTrailingObjects (OverloadToken<SILDIExprElement>) const {
4703
- return NumDIExprOperands;
4704
- }
4711
+ SIL_DEBUG_VAR_SUPPLEMENT_TRAILING_OBJS_IMPL ()
4705
4712
4706
4713
public:
4707
4714
// / Return the underlying variable declaration that this denotes,
0 commit comments