Merge remote-tracking branch 'origin/main' into rebranch

This commit is contained in:
swift-ci
2023-10-02 13:33:12 -07:00
8 changed files with 58 additions and 11 deletions

View File

@@ -107,7 +107,14 @@ private func tryDevirtualizeRelease(
// argument.
let functionRef = builder.createFunctionRef(dealloc)
let substitutionMap = context.getContextSubstitutionMap(for: type)
let substitutionMap: SubstitutionMap
if dealloc.isGenericFunction {
substitutionMap = context.getContextSubstitutionMap(for: type)
} else {
// In embedded Swift, dealloc might be a specialized deinit, so the substitution map on the old apply isn't valid for the new apply
substitutionMap = SubstitutionMap()
}
builder.createApply(function: functionRef, substitutionMap, arguments: [beginDealloc])
context.erase(instruction: lastRelease)
}

View File

@@ -739,6 +739,11 @@ static bool ParseLangArgs(LangOptions &Opts, ArgList &Args,
OPT_disable_testable_attr_requires_testable_module)) {
Opts.EnableTestableAttrRequiresTestableModule
= A->getOption().matches(OPT_enable_testable_attr_requires_testable_module);
} else if (FrontendOpts.RequestedAction ==
FrontendOptions::ActionType::TypecheckModuleFromInterface ||
FrontendOpts.RequestedAction ==
FrontendOptions::ActionType::CompileModuleFromInterface) {
Opts.EnableObjCAttrRequiresFoundation = false;
}
if (Args.getLastArg(OPT_debug_cycles))

View File

@@ -577,8 +577,13 @@ void irgen::emitBuiltinCall(IRGenFunction &IGF, const BuiltinInfo &Builtin,
// the error return register. We also have to pass a fake context
// argument due to how swiftcc works in clang.
auto fn = IGF.IGM.getWillThrowFunctionPointer();
auto error = args.claimNext();
if (IGF.IGM.Context.LangOpts.ThrowsAsTraps) {
return;
}
auto fn = IGF.IGM.getWillThrowFunctionPointer();
auto errorTy = IGF.IGM.Context.getErrorExistentialType();
auto errorBuffer = IGF.getCalleeErrorResultSlot(
SILType::getPrimitiveObjectType(errorTy), false);

View File

@@ -306,6 +306,15 @@ CalleeList CalleeCache::getDestructors(SILType type, bool isExactType) const {
if (isExactType || classDecl->isFinal()) {
// In case of a final class, just pick the deinit of the class.
SILDeclRef destructor = SILDeclRef(classDecl->getDestructor());
// In embedded Swift, we need the specialized destructor, not the generic
// one.
if (auto *vtable = M.lookUpSpecializedVTable(type)) {
if (auto entry = vtable->getEntry(M, destructor))
return CalleeList(entry->getImplementation());
return CalleeList();
}
if (SILFunction *destrImpl = M.lookUpFunction(destructor))
return CalleeList(destrImpl);
return CalleeList();

View File

@@ -760,14 +760,8 @@ static void addMidLevelFunctionPipeline(SILPassPipelinePlan &P) {
static void addLowLevelPassPipeline(SILPassPipelinePlan &P) {
P.startPipeline("LowLevel,Function", true /*isFunctionPassPipeline*/);
// MandatoryPerformanceOptimizations already took care of all specializations
// in embedded Swift mode, running the release devirtualizer might introduce
// more generic calls from non-generic functions, which breaks the assumptions
// of embedded Swift.
if (!P.getOptions().EmbeddedSwift) {
// Should be after FunctionSignatureOpts and before the last inliner.
P.addReleaseDevirtualizer();
}
addFunctionPasses(P, OptimizationLevelKind::LowLevel);

View File

@@ -0,0 +1,13 @@
// swift-interface-format-version: 1.0
// swift-module-flags: -module-name ExplicitInterfaceObjC
// REQUIRES: objc_interop, OS=macosx
// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -compile-module-from-interface -module-name ExplicitInterfaceObjC -explicit-interface-module-build -o %/t/ExplicitInterfaceObjC.swiftmodule %s -verify
// RUN: %target-swift-frontend -typecheck-module-from-interface -module-name ExplicitInterfaceObjC -explicit-interface-module-build -o %/t/ExplicitInterfaceObjC.swiftmodule %s -verify
import Swift
final public class Foo {
@objc deinit
}

View File

@@ -86,7 +86,9 @@ struct Main {
// CHECK-IR-NEXT: call {{.*}}@"$s4main5print_10terminatorys12StaticStringV_AEtF"
// CHECK-IR-NEXT: call {{.*}}@"$s4main5print_10terminatorys12StaticStringV_AEtF"
// CHECK-IR-NEXT: call {{.*}}@"$s4main3bar1oyAA7MyClassC_tF"
// CHECK-IR-NEXT: call {{.*}}@swift_release
// CHECK-IR-NEXT: call {{.*}}@swift_setDeallocating
// CHECK-IR-NEXT: call {{.*}}@"$s4main5print_10terminatorys12StaticStringV_AEtF"
// CHECK-IR-NEXT: call {{.*}}@"$s4main5print_10terminatorys12StaticStringV_AEtF"
// CHECK-IR-NEXT: call {{.*}}@llvm.lifetime.end.p0
// CHECK-IR-NEXT: call {{.*}}@"$s4main5print_10terminatorys12StaticStringV_AEtF"
// CHECK-IR-NEXT: call {{.*}}@swift_initStackObject

View File

@@ -0,0 +1,12 @@
// RUN: %target-swift-frontend -emit-ir %s -enable-experimental-feature Embedded -throws-as-traps | %FileCheck %s
// REQUIRES: VENDOR=apple
// REQUIRES: OS=macosx
public func test() {
withUnsafeTemporaryAllocation(byteCount: MemoryLayout<Int>.size, alignment: MemoryLayout<Int>.alignment) { p in
p[0] = 42
}
}
// CHECK-NOT: swift_willThrow