IRGen: Bring back the -enable-class-resilience staging flag

This commit is contained in:
Slava Pestov
2018-04-09 17:08:39 -07:00
parent 2232203424
commit c7853fe086
5 changed files with 20 additions and 7 deletions

View File

@@ -149,6 +149,9 @@ public:
/// Emit names of struct stored properties and enum cases.
unsigned EnableReflectionNames : 1;
/// Enables resilient class layout.
unsigned EnableClassResilience : 1;
/// Should we try to build incrementally by not emitting an object file if it
/// has the same IR hash as the module that we are preparing to emit?
///

View File

@@ -450,6 +450,9 @@ def enable_resilience : Flag<["-"], "enable-resilience">,
HelpText<"Compile the module to export resilient interfaces for all "
"public declarations by default">;
def enable_class_resilience : Flag<["-"], "enable-class-resilience">,
HelpText<"Enable resilient layout for classes containing resilient value types">;
def group_info_path : Separate<["-"], "group-info-path">,
HelpText<"The path to collect the group information of the compiled module">;

View File

@@ -902,6 +902,10 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
Opts.EnableReflectionNames = false;
}
if (Args.hasArg(OPT_enable_class_resilience)) {
Opts.EnableClassResilience = true;
}
for (const auto &Lib : Args.getAllArgValues(options::OPT_autolink_library))
Opts.LinkLibraries.push_back(LinkLibrary(Lib, LibraryKind::Library));

View File

@@ -1,10 +1,10 @@
// RUN: %empty-directory(%t)
// RUN: %utils/chex.py < %s > %t/class_resilience.swift
// RUN: %target-swift-frontend -emit-module -enable-resilience -emit-module-path=%t/resilient_struct.swiftmodule -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
// 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
// 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
// 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
// RUN: %target-swift-frontend -I %t -emit-ir -enable-resilience -O %t/class_resilience.swift
// 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
// 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
// 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
// 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
// RUN: %target-swift-frontend -I %t -emit-ir -enable-resilience -enable-class-resilience -O %t/class_resilience.swift
// CHECK: @"$S16class_resilience26ClassWithResilientPropertyC1s16resilient_struct4SizeVvpWvd" = hidden global [[INT]] 0
// CHECK: @"$S16class_resilience26ClassWithResilientPropertyC5colors5Int32VvpWvd" = hidden global [[INT]] 0

View File

@@ -80,6 +80,7 @@ class ResilienceTest(object):
compiler_flags = ['-emit-library', '-emit-module',
'-swift-version', '4',
'-Xfrontend', '-enable-resilience',
'-Xfrontend', '-enable-class-resilience',
'-D', config,
self.lib_src,
'-o', output_dylib]
@@ -103,8 +104,10 @@ class ResilienceTest(object):
def compile_main(self):
for config in self.config_dir_map:
output_obj = os.path.join(self.config_dir_map[config], 'main.o')
compiler_flags = ['-D', config, '-c', self.test_src, '-I',
self.config_dir_map[config], '-o', output_obj]
compiler_flags = ['-D', config, '-c', self.test_src,
'-Xfrontend', '-enable-class-resilience',
'-I', self.config_dir_map[config],
'-o', output_obj]
command = self.target_build_swift + compiler_flags
verbose_print_command(command)
returncode = subprocess.call(command)