Skip to content

Commit 1bde486

Browse files
committed
IRGen: Disable type layout based value witness generation at Onone
Type layout based witness generation can emit quite complex IR that will lead to code bloat if the llvm optimizer is not run. No need to use type layouts at Onone. rdar://61155295
1 parent 1331ac5 commit 1bde486

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

lib/Frontend/CompilerInvocation.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1292,6 +1292,9 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
12921292
OPT_disable_type_layouts)) {
12931293
Opts.UseTypeLayoutValueHandling
12941294
= A->getOption().matches(OPT_enable_type_layouts);
1295+
} else if (Opts.OptMode == OptimizationMode::NoOptimization) {
1296+
// Disable type layouts at Onone except if explictly requested.
1297+
Opts.UseTypeLayoutValueHandling = false;
12951298
}
12961299

12971300
Opts.UseSwiftCall = Args.hasArg(OPT_enable_swiftcall);

test/IRGen/typelayout_based_value_witness.swift

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
// RUN: %target-swift-frontend -enable-type-layout -primary-file %s -emit-ir | %FileCheck %s --check-prefix=CHECK
22
// RUN: %target-swift-frontend -enable-type-layout -primary-file %s -O -emit-ir | %FileCheck %s --check-prefix=OPT --check-prefix=OPT-%target-ptrsize
3+
// RUN: %target-swift-frontend -primary-file %s -emit-ir | %FileCheck %s --check-prefix=NOTL
34

45
public struct B<T> {
56
var x: T
@@ -11,6 +12,10 @@ public struct A<T> {
1112
var b: B<T>
1213
}
1314

15+
// NOTL-LABEL: define{{.*}} %swift.opaque* @"$s30typelayout_based_value_witness1AVwCP"(
16+
// NOTL: @"$s30typelayout_based_value_witness1BVMa"(
17+
// NOTL: }
18+
1419
// CHECK-LABEL: define{{.*}} %swift.opaque* @"$s30typelayout_based_value_witness1AVwCP"(
1520
// CHECK-NOT: @"$s30typelayout_based_value_witness1BVMa"(
1621
// CHECK: }

0 commit comments

Comments
 (0)