Skip to content

Commit 7236ece

Browse files
committed
Bitcast fixed-sized packs after allocating them.
Clients expect a %swift.opaque**; without the cast, local GEPs will go off into the weeds.
1 parent a5765ab commit 7236ece

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

lib/IRGen/GenPack.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1011,8 +1011,10 @@ StackAddress irgen::allocatePack(IRGenFunction &IGF, CanSILPackType packType) {
10111011
IGF.IGM.OpaquePtrTy, elementCount);
10121012

10131013
auto addr = IGF.createAlloca(allocType, IGF.IGM.getPointerAlignment());
1014-
IGF.Builder.CreateLifetimeStart(addr,
1015-
elementSize * elementCount);
1014+
IGF.Builder.CreateLifetimeStart(addr, elementSize * elementCount);
1015+
1016+
// We have an [N x opaque*]*; we need an opaque**.
1017+
addr = IGF.Builder.CreateElementBitCast(addr, IGF.IGM.OpaquePtrTy);
10161018
return addr;
10171019
}
10181020

test/IRGen/variadic_generics.sil

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ exit:
131131
// CHECK-LABEL: define {{.*}}@test_pack_alloc_2_static
132132
// CHECK: [[STACK:%[^,]+]] = alloca [2 x %swift.opaque*]
133133
// CHECK: call void @llvm.lifetime.start.p0i8
134+
// CHECK: [[CAST:%.*]] = bitcast [2 x %swift.opaque*]* [[STACK]] to %swift.opaque**
134135
// CHECK: call void @llvm.lifetime.end.p0i8
135136
sil @test_pack_alloc_2_static : $<each T> () -> () {
136137
%addr = alloc_pack $Pack{Int, Int}

0 commit comments

Comments
 (0)