Skip to content

Commit aab7c89

Browse files
Merge pull request #71767 from aschwaighofer/large_types_reg2mem_c_signature
LargeTypesReg2Mem: Remove overzealous assert
2 parents 4f61ec3 + 216b3c8 commit aab7c89

File tree

3 files changed

+46
-5
lines changed

3 files changed

+46
-5
lines changed

lib/IRGen/LoadableByAddress.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4245,11 +4245,7 @@ static void runPeepholesAndReg2Mem(SILPassManager *pm, SILModule *silMod,
42454245
if (&bb == entryBB) {
42464246
for (auto *arg : bb.getArguments()) {
42474247
auto ty = arg->getType();
4248-
// This is an idiosyncrasy of the large loadable types pass which
4249-
// ignores tuple types (considers them always "small").
42504248
if (assignment.isLargeLoadableType(ty)) {
4251-
assert(isa<TupleType>(ty.getASTType()));
4252-
;
42534249
auto addr = assignment.createAllocStack(ty);
42544250
assignment.mapValueToAddress(arg, addr);
42554251
// We will emit the store to initialize after parsing all other

test/IRGen/Inputs/large_c.h

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#pragma once
2+
3+
struct SamplesType {
4+
void* A;
5+
void* B;
6+
void* C;
7+
void* D;
8+
void* E;
9+
void* F;
10+
void* G;
11+
void* H;
12+
void* I;
13+
void* J;
14+
void* K;
15+
void* L;
16+
void* M;
17+
void* N;
18+
void* O;
19+
void* P;
20+
void* Q;
21+
void* R;
22+
void* S;
23+
void* T;
24+
void* U;
25+
void* V;
26+
void* W;
27+
void* X;
28+
void* Y;
29+
void* Z;
30+
void* AA;
31+
};

test/IRGen/loadable_by_address_reg2mem.sil

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// RUN: %target-swift-frontend %s -Xllvm -sil-print-after=loadable-address -c -o %t/t.o 2>&1 | %FileCheck %s
1+
// RUN: %target-swift-frontend %s -Xllvm -sil-print-after=loadable-address -import-objc-header %S/Inputs/large_c.h -c -o %t/t.o 2>&1 | %FileCheck %s
22

33
sil_stage canonical
44

@@ -215,3 +215,17 @@ bb0(%0 : $*Y):
215215
%t = tuple ()
216216
return %t : $()
217217
}
218+
219+
// CHECK: sil @test8
220+
// CHECK: bb0(%0 : $SamplesType):
221+
// CHECK: %1 = alloc_stack $SamplesType
222+
// CHECK: store %0 to %1 : $*SamplesType
223+
sil @helper : $@convention(thin) (SamplesType) -> ()
224+
225+
sil @test8 : $@convention(c) (SamplesType) -> () {
226+
bb0(%0 : $SamplesType):
227+
%1 = function_ref @helper : $@convention(thin) (SamplesType) -> ()
228+
%2 = apply %1(%0) : $@convention(thin) (SamplesType) -> ()
229+
%t = tuple ()
230+
return %t : $()
231+
}

0 commit comments

Comments
 (0)