How to determine backing data structure in compiler from Swift IR code and some more

Folks - as part of debugging a nasty infinite loop on s390x, problem is being narrowed down to some data being written to a structure which is identified in IR as follows:

Here is the Swift code:

var intarray = [11,12]
for _ in intarray {
}

Snippet of IR (non-optimized generation )

/=======================================/
%TSa = type <{ %Ts22_ContiguousArrayBufferV }>
%Ts22_ContiguousArrayBufferV = type <{ %Ts27_ContiguousArrayStorageBaseC* }>
%Ts27_ContiguousArrayStorageBaseC = type opaque
%struct._SwiftEmptyArrayStorage = type { %struct.HeapObject, %struct._SwiftArrayBodyStorage }
%struct.HeapObject = type { %struct.HeapMetadata*, %struct.InlineRefCountsPlaceholder }
%struct.HeapMetadata = type opaque
%struct.InlineRefCountsPlaceholder = type { i64 }
%struct._SwiftArrayBodyStorage = type { i64, i64 }
%swift.type = type { i64 }
%swift.refcounted = type { %swift.type*, i64 }
%Ts16IndexingIteratorVySaySiGG = type <{ %TSa, %TSi }>
%TSi = type <{ i64 }>
%TSiSg = type <{ [8 x i8], [1 x i8] }>
%Ts16IndexingIteratorV = type <{}>
%swift.opaque = type opaque
%TSq = type <{}>
%Ts16IndexingIteratorV.0 = type <{}>

/=======================================/

It seems like load/storeEnumTagSinglePayload routine is reading/writing to that storage but I am having difficulties figuring out where is that data structure (%TSiSg = type <{ [8 x i8], [1 x i8] }>) defined in Swift. If I read it correctly then it is some sort of packed structure containing 8 bytes of some type and then 1 byte of some other type.

I admit that my comprehension of Swift compiler code is still primitive so any tips will be greatly appreciated.

Any light on the following concepts will also be useful in the context of following code:

var intarray = [11,12]
for _ in intarray {
}

  1. It seems like intarray will be treated as “Enum” type by Swift compiler - if So, where in the code this data structure is being created?
    1.1 What is considered “Payload” in the above example - would the Enum that will end up describing the array under the covers (if it does so) consider each value of array (11/12) as a payload? So there will be 2 payloads associated with the array above (one for value 11 and another for value 12)?

  2. Value Witness Table -> Stepping through the code this table is often referenced - what exactly is it and how it is related to Arrays/Enum?

  3. storeEnumTagSinglePayload/loadEnumTagSinglePayload -> These two methods appear responsible for writing to the IR structure referenced earlier (%TSiSg = type <{ [8 x i8], [1 x i8] }>). What exactly are they trying to do and which data structures are they reading/writing to?
    3.3 If my understanding of “payload” is indeed correct then wouldn’t MultiplePayload Enum methods be called in this case since my array contains more than 1 value?
    3.4 What exactly is NumExtraInhabitants?

  4. Is there a “trace” functionality in Swift compiler that I can enable which will show me verbose logging of methods called when I compile/run Swift code?

Thanks again for any insights.