Remove the -resilience-bypass flag and functionality.

LLDB no longer depends on it.

rdar://problem/48018240
This commit is contained in:
Adrian Prantl
2019-03-19 12:50:56 -07:00
parent 7b654b372f
commit b8de883ca3
7 changed files with 13 additions and 100 deletions

View File

@@ -172,9 +172,6 @@ public:
/// expression evaluator. /// expression evaluator.
unsigned ForcePublicLinkage : 1; unsigned ForcePublicLinkage : 1;
/// Bypass resilience when accessing resilient frameworks.
unsigned EnableResilienceBypass : 1;
/// Force lazy initialization of class metadata /// Force lazy initialization of class metadata
/// Used on Windows to avoid cross-module references. /// Used on Windows to avoid cross-module references.
unsigned LazyInitializeClassMetadata : 1; unsigned LazyInitializeClassMetadata : 1;
@@ -230,21 +227,20 @@ public:
Verify(true), OptMode(OptimizationMode::NotSet), Verify(true), OptMode(OptimizationMode::NotSet),
Sanitizers(OptionSet<SanitizerKind>()), Sanitizers(OptionSet<SanitizerKind>()),
DebugInfoLevel(IRGenDebugInfoLevel::None), DebugInfoLevel(IRGenDebugInfoLevel::None),
DebugInfoFormat(IRGenDebugInfoFormat::None), DebugInfoFormat(IRGenDebugInfoFormat::None), UseJIT(false),
UseJIT(false), IntegratedREPL(false), IntegratedREPL(false), DisableLLVMOptzns(false),
DisableLLVMOptzns(false), DisableSwiftSpecificLLVMOptzns(false), DisableSwiftSpecificLLVMOptzns(false), DisableLLVMSLPVectorizer(false),
DisableLLVMSLPVectorizer(false), DisableFPElim(true), Playground(false), DisableFPElim(true), Playground(false), EmitStackPromotionChecks(false),
EmitStackPromotionChecks(false), PrintInlineTree(false), PrintInlineTree(false), EmbedMode(IRGenEmbedMode::None),
EmbedMode(IRGenEmbedMode::None), HasValueNamesSetting(false), HasValueNamesSetting(false), ValueNames(false),
ValueNames(false), EnableReflectionMetadata(true), EnableReflectionMetadata(true), EnableReflectionNames(true),
EnableReflectionNames(true), EnableAnonymousContextMangledNames(false), EnableAnonymousContextMangledNames(false), ForcePublicLinkage(false),
ForcePublicLinkage(false), LazyInitializeClassMetadata(false),
EnableResilienceBypass(false), LazyInitializeClassMetadata(false),
LazyInitializeProtocolConformances(false), DisableLegacyTypeInfo(false), LazyInitializeProtocolConformances(false), DisableLegacyTypeInfo(false),
UseIncrementalLLVMCodeGen(true), UseSwiftCall(false), UseIncrementalLLVMCodeGen(true), UseSwiftCall(false),
GenerateProfile(false), EnableDynamicReplacementChaining(false), GenerateProfile(false), EnableDynamicReplacementChaining(false),
DisableRoundTripDebugTypes(false), DisableRoundTripDebugTypes(false), CmdArgs(),
CmdArgs(), SanitizeCoverage(llvm::SanitizerCoverageOptions()), SanitizeCoverage(llvm::SanitizerCoverageOptions()),
TypeInfoFilter(TypeInfoDumpFilter::All) {} TypeInfoFilter(TypeInfoDumpFilter::All) {}
// Get a hash of all options which influence the llvm compilation but are not // Get a hash of all options which influence the llvm compilation but are not

View File

@@ -517,9 +517,6 @@ def prebuilt_module_cache_path_EQ :
Joined<["-"], "prebuilt-module-cache-path=">, Joined<["-"], "prebuilt-module-cache-path=">,
Alias<prebuilt_module_cache_path>; Alias<prebuilt_module_cache_path>;
def enable_resilience_bypass : Flag<["-"], "enable-resilience-bypass">,
HelpText<"Completely bypass resilience when accessing types in resilient frameworks">;
def force_public_linkage : Flag<["-"], "force-public-linkage">, def force_public_linkage : Flag<["-"], "force-public-linkage">,
HelpText<"Force public linkage for private symbols. Used by LLDB.">; HelpText<"Force public linkage for private symbols. Used by LLDB.">;

View File

@@ -1082,10 +1082,6 @@ static bool ParseIRGenArgs(IRGenOptions &Opts, ArgList &Args,
Opts.EnableReflectionNames = false; Opts.EnableReflectionNames = false;
} }
if (Args.hasArg(OPT_enable_resilience_bypass)) {
Opts.EnableResilienceBypass = true;
}
if (Args.hasArg(OPT_force_public_linkage)) { if (Args.hasArg(OPT_force_public_linkage)) {
Opts.ForcePublicLinkage = true; Opts.ForcePublicLinkage = true;
} }

View File

@@ -1169,14 +1169,6 @@ static bool doesPlatformSupportObjCMetadataUpdateCallback(
TypeConverter::TypeConverter(IRGenModule &IGM) TypeConverter::TypeConverter(IRGenModule &IGM)
: IGM(IGM), : IGM(IGM),
FirstType(invalidTypeInfo()) { FirstType(invalidTypeInfo()) {
// FIXME: In LLDB, everything is completely fragile, so that IRGen can query
// the size of resilient types. Of course this is not the right long term
// solution, because it won't work once the swiftmodule file is not in
// sync with the binary module. Once LLDB can calculate type layouts at
// runtime (using remote mirrors or some other mechanism), we can remove this.
if (IGM.IRGen.Opts.EnableResilienceBypass)
LoweringMode = Mode::CompletelyFragile;
const auto &Triple = IGM.Context.LangOpts.Target; const auto &Triple = IGM.Context.LangOpts.Target;
SupportsObjCMetadataUpdateCallback = SupportsObjCMetadataUpdateCallback =

View File

@@ -659,24 +659,6 @@ bool irgen::isTypeMetadataAccessTrivial(IRGenModule &IGM, CanType type) {
auto expansion = ResilienceExpansion::Maximal; auto expansion = ResilienceExpansion::Maximal;
// Normally, if a value type is known to have a fixed layout to us, we will
// have emitted fully initialized metadata for it, including a payload size
// field for enum metadata for example, allowing the type metadata to be
// used in other resilience domains without initialization.
//
// However, when -enable-resilience-bypass is on, we might be using a value
// type from another module built with resilience enabled. In that case, the
// type looks like it has fixed size to us, since we're bypassing resilience,
// but the metadata still requires runtime initialization, so its incorrect
// to reference it directly.
//
// While unconditionally using minimal expansion is correct, it is not as
// efficient as it should be, so only do so if -enable-resilience-bypass is on.
//
// FIXME: All of this goes away once lldb supports resilience.
if (IGM.IRGen.Opts.EnableResilienceBypass)
expansion = ResilienceExpansion::Minimal;
// Resiliently-sized metadata access always requires an accessor. // Resiliently-sized metadata access always requires an accessor.
return (IGM.getTypeInfoForUnlowered(type).isFixedSize(expansion)); return (IGM.getTypeInfoForUnlowered(type).isFixedSize(expansion));
} }

View File

@@ -6,11 +6,9 @@
// RUN: -emit-module-path=%t/resilient_struct.swiftmodule \ // RUN: -emit-module-path=%t/resilient_struct.swiftmodule \
// RUN: -module-name=resilient_struct %S/../Inputs/resilient_struct.swift // RUN: -module-name=resilient_struct %S/../Inputs/resilient_struct.swift
// //
// RUN: %target-swift-frontend -g -I %t -emit-ir -enable-library-evolution %s -o - \ // RUN: %target-swift-frontend -g -I %t -emit-ir -enable-library-evolution %s \
// RUN: | %FileCheck %s // RUN: -o - | %FileCheck %s
// //
// RUN: %target-swift-frontend -g -I %t -emit-ir -enable-library-evolution %s -o - \
// RUN: -enable-resilience-bypass | %FileCheck %s --check-prefix=CHECK-LLDB
import resilient_struct import resilient_struct
// CHECK-LABEL: define{{.*}} swiftcc void @"$s17struct_resilience9takesSizeyy010resilient_A00D0VF"(%swift.opaque* noalias nocapture) // CHECK-LABEL: define{{.*}} swiftcc void @"$s17struct_resilience9takesSizeyy010resilient_A00D0VF"(%swift.opaque* noalias nocapture)
@@ -29,17 +27,9 @@ func f() {
// CHECK-SAME: metadata !DIExpression(DW_OP_deref)) // CHECK-SAME: metadata !DIExpression(DW_OP_deref))
// CHECK: %[[S1:.*]] = alloca i8, // CHECK: %[[S1:.*]] = alloca i8,
// CHECK: store i8* %[[S1]], i8** %[[ADDR]] // CHECK: store i8* %[[S1]], i8** %[[ADDR]]
// CHECK-LLDB: %[[ADDR:.*]] = alloca %T16resilient_struct4SizeV
// CHECK-LLDB: call void @llvm.dbg.declare(metadata %T16resilient_struct4SizeV* %[[ADDR]],
// CHECK-LLDB-SAME: metadata ![[V1:[0-9]+]],
// CHECK-LLDB-SAME: metadata !DIExpression())
} }
f() f()
// CHECK: ![[TY:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Size", // CHECK: ![[TY:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Size",
// CHECK: ![[V1]] = !DILocalVariable(name: "s1", {{.*}}type: ![[TY]]) // CHECK: ![[V1]] = !DILocalVariable(name: "s1", {{.*}}type: ![[TY]])
// CHECK-LLDB: ![[TY:[0-9]+]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Size",
// CHECK-LLDB: ![[V1]] = !DILocalVariable(name: "s1", {{.*}}type: ![[TY]])

View File

@@ -1,40 +0,0 @@
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -emit-module -enable-library-evolution -emit-module-path=%t/first.swiftmodule -module-name=first %S/Inputs/resilience_bypass/first.swift
// RUN: %target-swift-frontend -emit-module -emit-module-path=%t/second.swiftmodule -module-name=second %S/Inputs/resilience_bypass/second.swift -I %t
// RUN: %target-swift-frontend -emit-ir -enable-resilience-bypass %s -I %t | %FileCheck %s -DINT=i%target-ptrsize
import first
import second
// CHECK: define{{( dllexport| protected)?}} swiftcc [[INT]] @"$s17resilience_bypass7getSizeSiyF"() {{.*}} {
// CHECK-NEXT: entry:
// FIXME: The metadata accessor call is not necessary
// CHECK-NEXT: [[RESPONSE:%.*]] = call swiftcc %swift.metadata_response @"$s6second1EOMa"
// CHECK-NEXT: [[METADATA:%.*]] = extractvalue %swift.metadata_response [[RESPONSE]], 0
// CHECK-NEXT: ret [[INT]] {{5|9}}
// CHECK-NEXT: }
public func getSize() -> Int {
return MemoryLayout<E>.size
}
public func makeE(_ s: S) -> E {
return .b(s)
}
// CHECK: define{{( dllexport| protected)?}} swiftcc void @"$s17resilience_bypass7makeAnyyyp5first1SVF"(
// CHECK-NEXT: entry:
// Make sure we form the existential using the result of the metadata accessor, instead of
// directly using the address of the metadata global.
//
// FIXME: The metadata global should have hidden linkage to rule out this kind of bug.
// CHECK-NEXT: [[RESPONSE:%.*]] = call swiftcc %swift.metadata_response @"$s6second1EOMa"
public func makeAny(_ s: S) -> Any {
return makeE(s)
}