Skip to content

Commit 7bb7326

Browse files
Merge pull request #82282 from nate-chandler/cherrypick/release/6.2/rdar151726387
6.2: [IRGen] Fix FixedArray of fixedSize 1 element addressing
2 parents 2e18973 + 2cf7ef5 commit 7bb7326

File tree

2 files changed

+30
-2
lines changed

2 files changed

+30
-2
lines changed

lib/IRGen/GenArray.cpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,15 @@ class ArrayTypeInfoBase : public BaseTypeInfo {
5353
return;
5454
}
5555
if (fixedSize == 1) {
56-
// only one element to operate on
57-
return body(addrs);
56+
auto zero = llvm::ConstantInt::get(IGF.IGM.IntPtrTy, 0);
57+
// only one element to operate on; index to it in each array
58+
SmallVector<Address, 2> eltAddrs;
59+
eltAddrs.reserve(addrs.size());
60+
for (auto index : indices(addrs)) {
61+
eltAddrs.push_back(Element.indexArray(IGF, addrs[index], zero,
62+
getElementSILType(IGF.IGM, T)));
63+
}
64+
return body(eltAddrs);
5865
}
5966

6067
auto arraySize = getArraySize(IGF, T);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// RUN: %target-swift-frontend -parse-sil -emit-ir %s
2+
3+
sil_stage canonical
4+
5+
import Builtin
6+
import Swift
7+
8+
struct O {
9+
var arr: Builtin.FixedArray<1, I>
10+
struct I {
11+
var eyes: SIMD64<Int8>
12+
var neighs: String
13+
}
14+
}
15+
16+
sil @copy : $@convention(thin) (@in_guaranteed O) -> (@out O) {
17+
entry(%out : $*O, %in : $*O):
18+
copy_addr %in to [init] %out : $*O
19+
%retval = tuple ()
20+
return %retval : $()
21+
}

0 commit comments

Comments
 (0)