Skip to content

NCGenerics: fix partial backdeployment support #73328

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 4 commits into from

Conversation

kavon
Copy link
Member

@kavon kavon commented Apr 29, 2024

When the type substitution is concrete, we can obtain metadata on older runtimes for the type with a noncopyable generic parameter. We just have to avoid the demangling strategy.

resolves rdar://126239335

@kavon kavon requested a review from rjmccall April 29, 2024 22:23
@kavon
Copy link
Member Author

kavon commented Apr 29, 2024

@swift-ci smoke test

@kavon
Copy link
Member Author

kavon commented Apr 30, 2024

About 105 tests failed, 50 or so with the following crash. Looks like there's a bit more to this than I thought.

reference storage type should have been converted by SILGen
UNREACHABLE executed at /Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/swift/lib/IRGen/MetadataRequest.cpp:2159!
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend -target x86_64-apple-macosx10.13 -module-cache-path /Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/swift-test-results/x86_64-apple-macosx10.13/clang-module-cache -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.2.sdk -swift-version 4 -define-availability "SwiftStdlib 9999:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999" -define-availability "SwiftStdlib 5.0:macOS 10.14.4, iOS 12.2, watchOS 5.2, tvOS 12.2" -define-availability "SwiftStdlib 5.1:macOS 10.15, iOS 13.0, watchOS 6.0, tvOS 13.0" -define-availability "SwiftStdlib 5.2:macOS 10.15.4, iOS 13.4, watchOS 6.2, tvOS 13.4" -define-availability "SwiftStdlib 5.3:macOS 11.0, iOS 14.0, watchOS 7.0, tvOS 14.0" -define-availability "SwiftStdlib 5.4:macOS 11.3, iOS 14.5, watchOS 7.4, tvOS 14.5" -define-availability "SwiftStdlib 5.5:macOS 12.0, iOS 15.0, watchOS 8.0, tvOS 15.0" -define-availability "SwiftStdlib 5.6:macOS 12.3, iOS 15.4, watchOS 8.5, tvOS 15.4" -define-availability "SwiftStdlib 5.7:macOS 13.0, iOS 16.0, watchOS 9.0, tvOS 16.0" -define-availability "SwiftStdlib 5.8:macOS 13.3, iOS 16.4, watchOS 9.4, tvOS 16.4" -define-availability "SwiftStdlib 5.9:macOS 14.0, iOS 17.0, watchOS 10.0, tvOS 17.0" -define-availability "SwiftStdlib 5.10:macOS 14.4, iOS 17.4, watchOS 10.4, tvOS 17.4, visionOS 1.1" -define-availability "SwiftStdlib 6.0:macOS 9999, iOS 9999, watchOS 9999, tvOS 9999, visionOS 9999" -typo-correction-limit 10 -module-name builtins -parse-stdlib -Xllvm -sil-disable-pass=target-constant-folding -disable-access-control -primary-file /Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/swift/test/IRGen/builtins.swift -emit-ir -o - -disable-objc-attr-requires-foundation-module
1.	Apple Swift version 6.0-dev (LLVM 85bfcc565707685, Swift b014e9eeccfed66)
2.	Compiling with effective version 4.1.50
3.	While evaluating request IRGenRequest(IR Generation for file "/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/swift/test/IRGen/builtins.swift")
4.	While emitting IR for source file /Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/swift/test/IRGen/builtins.swift
5.	While emitting field type metadata 'W' (at /Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/swift/test/IRGen/builtins.swift:527:1)
 #0 0x000000010fa34388 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x106409388)
 #1 0x000000010fa32528 llvm::sys::RunSignalHandlers() (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x106407528)
 #2 0x000000010fa349ee SignalHandler(int) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x1064099ee)
 #3 0x00007ff80cdff5ed (/usr/lib/system/libsystem_platform.dylib+0x7ff8004255ed)
 #4 0x0000000000000000 
 #5 0x00007ff80ccf8b45 (/usr/lib/system/libsystem_c.dylib+0x7ff80031eb45)
 #6 0x000000010f9a3945 llvm::llvm_unreachable_internal(char const*, char const*, unsigned int) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x106378945)
 #7 0x0000000109ee5803 emitDirectTypeMetadataRef(swift::irgen::IRGenFunction&, swift::CanType, swift::irgen::DynamicMetadataRequest) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x1008ba803)
 #8 0x0000000109eeb696 swift::irgen::MetadataResponse llvm::function_ref<swift::irgen::MetadataResponse (swift::irgen::IRGenFunction&, swift::irgen::DynamicMetadataRequest, llvm::Constant*)>::callback_fn<swift::irgen::createDirectTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, bool)::$_5>(long, swift::irgen::IRGenFunction&, swift::irgen::DynamicMetadataRequest, llvm::Constant*) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x1008c0696)
 #9 0x0000000109eeb559 swift::irgen::MetadataResponse llvm::function_ref<swift::irgen::MetadataResponse (swift::irgen::IRGenFunction&, swift::irgen::Explosion&)>::callback_fn<swift::irgen::createTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::irgen::CacheStrategy, llvm::function_ref<swift::irgen::MetadataResponse (swift::irgen::IRGenFunction&, swift::irgen::DynamicMetadataRequest, llvm::Constant*)>, bool)::$_4>(long, swift::irgen::IRGenFunction&, swift::irgen::Explosion&) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x1008c0559)
#10 0x0000000109ede346 swift::irgen::emitCacheAccessFunction(swift::irgen::IRGenModule&, llvm::Function*, llvm::Constant*, llvm::Type*, swift::irgen::CacheStrategy, llvm::function_ref<swift::irgen::MetadataResponse (swift::irgen::IRGenFunction&, swift::irgen::Explosion&)>, bool) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x1008b3346)
#11 0x0000000109ee0572 swift::irgen::createTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType, swift::irgen::CacheStrategy, llvm::function_ref<swift::irgen::MetadataResponse (swift::irgen::IRGenFunction&, swift::irgen::DynamicMetadataRequest, llvm::Constant*)>, bool) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x1008b5572)
#12 0x0000000109ee5bd1 swift::irgen::getOrCreateTypeMetadataAccessFunction(swift::irgen::IRGenModule&, swift::CanType) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x1008babd1)
#13 0x0000000109ee0a14 swift::irgen::IRGenFunction::emitTypeMetadataRef(swift::CanType, swift::irgen::DynamicMetadataRequest) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x1008b5a14)
#14 0x0000000109ee1167 swift::irgen::IRGenFunction::emitTypeMetadataRef(swift::CanType) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x1008b6167)
#15 0x0000000109db98ca clang::CodeGen::ConstantInitFuture llvm::function_ref<clang::CodeGen::ConstantInitFuture (swift::irgen::ConstantInitBuilder&)>::callback_fn<getTypeRefByFunction(swift::irgen::IRGenModule&, swift::CanGenericSignature, swift::CanType)::$_5>(long, swift::irgen::ConstantInitBuilder&) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x10078e8ca)
#16 0x0000000109edc113 swift::irgen::IRGenModule::getAddrOfStringForMetadataRef(llvm::StringRef, unsigned int, bool, llvm::function_ref<clang::CodeGen::ConstantInitFuture (swift::irgen::ConstantInitBuilder&)>) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x1008b1113)
#17 0x0000000109db9126 getTypeRefByFunction(swift::irgen::IRGenModule&, swift::CanGenericSignature, swift::CanType) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x10078e126)
#18 0x0000000109db5d41 getTypeRefImpl(swift::irgen::IRGenModule&, swift::CanType, swift::CanGenericSignature, swift::irgen::MangledTypeRefRole) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x10078ad41)
#19 0x0000000109db9f95 ReflectionMetadataBuilder::addTypeRef(swift::CanType, swift::CanGenericSignature, swift::irgen::MangledTypeRefRole) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x10078ef95)
#20 0x0000000109dbd290 FieldTypeMetadataBuilder::addField(swift::reflection::FieldRecordFlags, swift::Type, llvm::StringRef) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x100792290)
#21 0x0000000109dbd0fc FieldTypeMetadataBuilder::addField(swift::irgen::Field) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x1007920fc)
#22 0x0000000109ef4f0c swift::irgen::forEachField(swift::irgen::IRGenModule&, swift::NominalTypeDecl const*, llvm::function_ref<void (swift::irgen::Field)>) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x1008c9f0c)
#23 0x0000000109dbcd64 FieldTypeMetadataBuilder::layoutRecord() (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x100791d64)
#24 0x0000000109dbcbd3 FieldTypeMetadataBuilder::layout() (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x100791bd3)
#25 0x0000000109dba299 ReflectionMetadataBuilder::emit(std::__1::optional<llvm::function_ref<llvm::Constant* (swift::irgen::IRGenModule&, swift::irgen::ConstantInit)>>, char const*) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x10078f299)
#26 0x0000000109db8cec FieldTypeMetadataBuilder::emit() (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x10078dcec)
#27 0x0000000109db885d swift::irgen::IRGenModule::emitFieldDescriptor(swift::NominalTypeDecl const*) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x10078d85d)
#28 0x0000000109dbf057 swift::irgen::IRGenModule::emitStructDecl(swift::StructDecl*) (/Users/ec2-user/jenkins/workspace/swift-PR-macos-smoke-test/branch-main/build/buildbot_incremental/swift-macosx-x86_64/bin/swift-frontend+0x100794057)

@kavon kavon marked this pull request as draft May 26, 2024 00:10
@kavon kavon force-pushed the partial-backdeploy-ncgenerics branch from 5dc2b1f to 116cb4c Compare June 4, 2024 22:20
@kavon
Copy link
Member Author

kavon commented Jun 4, 2024

@swift-ci test

@kavon
Copy link
Member Author

kavon commented Jun 13, 2024

@swift-ci test macOS

1 similar comment
@kavon
Copy link
Member Author

kavon commented Jun 15, 2024

@swift-ci test macOS

kavon added 4 commits June 25, 2024 13:31
When the type substitution is concrete, we can obtain metadata on older
runtimes for the type with a noncopyable generic parameter. We just have
to avoid the demangling strategy.

resolves rdar://126239335
@kavon kavon force-pushed the partial-backdeploy-ncgenerics branch from 112eeff to f054cbd Compare June 27, 2024 19:04
@kavon
Copy link
Member Author

kavon commented Jul 16, 2024

subsumed by #74864 and #74918

@kavon kavon closed this Jul 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant