Skip to content

Commit c7853fe

Browse files
committed
IRGen: Bring back the -enable-class-resilience staging flag
1 parent 2232203 commit c7853fe

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

include/swift/AST/IRGenOptions.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,9 @@ class IRGenOptions {
149149
/// Emit names of struct stored properties and enum cases.
150150
unsigned EnableReflectionNames : 1;
151151

152+
/// Enables resilient class layout.
153+
unsigned EnableClassResilience : 1;
154+
152155
/// Should we try to build incrementally by not emitting an object file if it
153156
/// has the same IR hash as the module that we are preparing to emit?
154157
///

include/swift/Option/FrontendOptions.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,9 @@ def enable_resilience : Flag<["-"], "enable-resilience">,
450450
HelpText<"Compile the module to export resilient interfaces for all "
451451
"public declarations by default">;
452452

453+
def enable_class_resilience : Flag<["-"], "enable-class-resilience">,
454+
HelpText<"Enable resilient layout for classes containing resilient value types">;
455+
453456
def group_info_path : Separate<["-"], "group-info-path">,
454457
HelpText<"The path to collect the group information of the compiled module">;
455458

lib/Frontend/CompilerInvocation.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -902,6 +902,10 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
902902
Opts.EnableReflectionNames = false;
903903
}
904904

905+
if (Args.hasArg(OPT_enable_class_resilience)) {
906+
Opts.EnableClassResilience = true;
907+
}
908+
905909
for (const auto &Lib : Args.getAllArgValues(options::OPT_autolink_library))
906910
Opts.LinkLibraries.push_back(LinkLibrary(Lib, LibraryKind::Library));
907911

test/IRGen/class_resilience.swift

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
// RUN: %empty-directory(%t)
22
// RUN: %utils/chex.py < %s > %t/class_resilience.swift
3-
// RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_struct.swiftmodule -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
4-
// RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_enum.swiftmodule -module-name=resilient_enum -I %t %S/../Inputs/resilient_enum.swift
5-
// RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_class.swiftmodule -module-name=resilient_class -I %t %S/../Inputs/resilient_class.swift
6-
// RUN: %target-swift-frontend -I %t -emit-ir -enable-resilience %t/class_resilience.swift | %FileCheck %t/class_resilience.swift --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize -DINT=i%target-ptrsize
7-
// RUN: %target-swift-frontend -I %t -emit-ir -enable-resilience -O %t/class_resilience.swift
3+
// RUN: %target-swift-frontend -emit-module -enable-resilience -enable-class-resilience -emit-module-path=%t/resilient_struct.swiftmodule -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
4+
// RUN: %target-swift-frontend -emit-module -enable-resilience -enable-class-resilience -emit-module-path=%t/resilient_enum.swiftmodule -module-name=resilient_enum -I %t %S/../Inputs/resilient_enum.swift
5+
// RUN: %target-swift-frontend -emit-module -enable-resilience -enable-class-resilience -emit-module-path=%t/resilient_class.swiftmodule -module-name=resilient_class -I %t %S/../Inputs/resilient_class.swift
6+
// RUN: %target-swift-frontend -I %t -emit-ir -enable-resilience -enable-class-resilience %t/class_resilience.swift | %FileCheck %t/class_resilience.swift --check-prefix=CHECK --check-prefix=CHECK-%target-ptrsize -DINT=i%target-ptrsize
7+
// RUN: %target-swift-frontend -I %t -emit-ir -enable-resilience -enable-class-resilience -O %t/class_resilience.swift
88

99
// CHECK: @"$S16class_resilience26ClassWithResilientPropertyC1s16resilient_struct4SizeVvpWvd" = hidden global [[INT]] 0
1010
// CHECK: @"$S16class_resilience26ClassWithResilientPropertyC5colors5Int32VvpWvd" = hidden global [[INT]] 0

utils/rth

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ class ResilienceTest(object):
8080
compiler_flags = ['-emit-library', '-emit-module',
8181
'-swift-version', '4',
8282
'-Xfrontend', '-enable-resilience',
83+
'-Xfrontend', '-enable-class-resilience',
8384
'-D', config,
8485
self.lib_src,
8586
'-o', output_dylib]
@@ -103,8 +104,10 @@ class ResilienceTest(object):
103104
def compile_main(self):
104105
for config in self.config_dir_map:
105106
output_obj = os.path.join(self.config_dir_map[config], 'main.o')
106-
compiler_flags = ['-D', config, '-c', self.test_src, '-I',
107-
self.config_dir_map[config], '-o', output_obj]
107+
compiler_flags = ['-D', config, '-c', self.test_src,
108+
'-Xfrontend', '-enable-class-resilience',
109+
'-I', self.config_dir_map[config],
110+
'-o', output_obj]
108111
command = self.target_build_swift + compiler_flags
109112
verbose_print_command(command)
110113
returncode = subprocess.call(command)

0 commit comments

Comments
 (0)