Skip to content

Commit b5881d9

Browse files
authored
Merge pull request #64191 from rjmccall/bitcast-alloc-pack
Bitcast fixed-sized packs after allocating them.
2 parents 09ade25 + 7236ece commit b5881d9

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
@@ -1023,8 +1023,10 @@ StackAddress irgen::allocatePack(IRGenFunction &IGF, CanSILPackType packType) {
10231023
IGF.IGM.OpaquePtrTy, elementCount);
10241024

10251025
auto addr = IGF.createAlloca(allocType, IGF.IGM.getPointerAlignment());
1026-
IGF.Builder.CreateLifetimeStart(addr,
1027-
elementSize * elementCount);
1026+
IGF.Builder.CreateLifetimeStart(addr, elementSize * elementCount);
1027+
1028+
// We have an [N x opaque*]*; we need an opaque**.
1029+
addr = IGF.Builder.CreateElementBitCast(addr, IGF.IGM.OpaquePtrTy);
10281030
return addr;
10291031
}
10301032

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)