Skip to content

[DebugInfo] Fix handling of @_originallyDefinedIn types #78104

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

Merged
merged 1 commit into from
Dec 18, 2024

Conversation

augusto2112
Copy link
Contributor

Emit an imported declaration for @_originallyDefinedIn under the real module that these types live in.

This patch also changes the mangling for the debugger to respect @_originallyDefinedIn, and fixes a bug where @_originallyDefinedIn that should be ignored was still being used when mangling.

rdar://137146961

@augusto2112
Copy link
Contributor Author

@swift-ci test source compatibility

1 similar comment
@augusto2112
Copy link
Contributor Author

@swift-ci test source compatibility

@augusto2112
Copy link
Contributor Author

@swift-ci test source compatibility

@augusto2112
Copy link
Contributor Author

The source compatibility error seems to be unrelated to this patch:

Begin Error in Function: '$s9swiftlintyyYbcfU_'
Found outside of lifetime use?!
Value:   %126 = begin_borrow %125 : $LintCommand         // users: %128, %127
Consuming User:   end_borrow %126 : $LintCommand                  // id: %128
Non Consuming User:   %133 = apply %132(%127, %131, %2) : $@convention(method) (@guaranteed String, @guaranteed @noescape @callee_guaranteed @substituted <τ_0_0> (@in_guaranteed τ_0_0) -> () for <CommandantError<()>>, @guaranteed CommandRegistry<CommandantError<()>>) -> Never
Block: bb0

End Error in Function: '$s9swiftlintyyYbcfU_'
Found ownership error?!
<unknown>:0: error: fatal error encountered during compilation; please submit a bug report (https://swift.org/contributing/#reporting-bugs)
<unknown>:0: note: triggering standard assertion failure routine
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-private/swift-PR-source-compat-suite-macos/build/compat_macos/install/toolchain/usr/bin/swift-frontend -frontend -c /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/Source/swiftlint/Commands/AnalyzeCommand.swift /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/Source/swiftlint/Commands/AutoCorrectCommand.swift /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/Source/swiftlint/Commands/GenerateDocsCommand.swift /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/Source/swiftlint/Commands/LintCommand.swift /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/Source/swiftlint/Commands/RulesCommand.swift /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/Source/swiftlint/Commands/VersionCommand.swift /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/Source/swiftlint/Extensions/Configuration+CommandLine.swift /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/Source/swiftlint/Extensions/Reporter+CommandLine.swift /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/Source/swiftlint/Extensions/shim.swift /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/Source/swiftlint/Helpers/Benchmark.swift /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/Source/swiftlint/Helpers/CommonOptions.swift /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/Source/swiftlint/Helpers/CompilerArgumentsExtractor.swift /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/Source/swiftlint/Helpers/LintOrAnalyzeCommand.swift /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/Source/swiftlint/Helpers/LintableFilesVisitor.swift /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/Source/swiftlint/main.swift -supplementary-output-file-map /var/folders/bb/hcrjxg1s0b96pfst0ymhmp240000gn/T/TemporaryDirectory.cGo7ia/supplementaryOutputs-1 -target x86_64-apple-macosx10.13 -enable-objc-interop -sdk /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -I /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/Modules -I /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -g -debug-info-format=dwarf -dwarf-version=4 -module-cache-path /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/ModuleCache -swift-version 4 -O -D SWIFT_PACKAGE -empty-abi-descriptor -disable-sandbox -resource-dir /Users/ec2-user/jenkins/workspace-private/swift-PR-source-compat-suite-macos/build/compat_macos/install/toolchain/usr/lib/swift -file-compilation-dir /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy -Xcc -fmodule-map-file=/Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/CYaml.build/module.modulemap -Xcc -I -Xcc /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/checkouts/Yams/Sources/CYaml/include -Xcc -fmodule-map-file=/Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/SourceKit.build/module.modulemap -Xcc -I -Xcc /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/checkouts/SourceKitten/Source/SourceKit/include -Xcc -fmodule-map-file=/Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/Clang_C.build/module.modulemap -Xcc -I -Xcc /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/checkouts/SourceKitten/Source/Clang_C/include -Xcc -isysroot -Xcc /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk -Xcc -F -Xcc /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -Xcc -fPIC -Xcc -g -module-name swiftlint -in-process-plugin-server-path /Users/ec2-user/jenkins/workspace-private/swift-PR-source-compat-suite-macos/build/compat_macos/install/toolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Users/ec2-user/jenkins/workspace-private/swift-PR-source-compat-suite-macos/build/compat_macos/install/toolchain/usr/lib/swift/host/plugins -plugin-path /Users/ec2-user/jenkins/workspace-private/swift-PR-source-compat-suite-macos/build/compat_macos/install/toolchain/usr/local/lib/swift/host/plugins -target-sdk-version 14.2 -target-sdk-name macosx14.2 -external-plugin-path /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -enable-default-cmo -num-threads 12 -o /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/swiftlint.build/AnalyzeCommand.swift.o -o /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/swiftlint.build/AutoCorrectCommand.swift.o -o /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/swiftlint.build/GenerateDocsCommand.swift.o -o /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/swiftlint.build/LintCommand.swift.o -o /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/swiftlint.build/RulesCommand.swift.o -o /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/swiftlint.build/VersionCommand.swift.o -o /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/swiftlint.build/Configuration+CommandLine.swift.o -o /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/swiftlint.build/Reporter+CommandLine.swift.o -o /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/swiftlint.build/shim.swift.o -o /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/swiftlint.build/Benchmark.swift.o -o /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/swiftlint.build/CommonOptions.swift.o -o /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/swiftlint.build/CompilerArgumentsExtractor.swift.o -o /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/swiftlint.build/LintOrAnalyzeCommand.swift.o -o /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/swiftlint.build/LintableFilesVisitor.swift.o -o /Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/.build/x86_64-apple-macosx/release/swiftlint.build/main.swift.o
1.	Apple Swift version 6.2-dev (LLVM be88cf92c709b2a, Swift c7408fa067de3f5)
2.	Compiling with effective version 4.1.50
3.	While evaluating request ExecuteSILPipelineRequest(Run pipelines { PrepareOptimizationPasses, EarlyModulePasses, HighLevel,Function+EarlyLoopOpt, HighLevel,Module+StackPromote, MidLevel,Function, ClosureSpecialize, LowLevel,Function, LateLoopOpt, SIL Debug Info Generator } on SIL for swiftlint)
4.	While running pass #15689 SILFunctionTransform "CopyPropagation" on SILFunction "@$s9swiftlintyyYbcfU_".
 for expression at [/Users/ec2-user/jenkins/workspace/swift-PR-source-compat-suite-macos/swift-source-compat-suite/project_cache/SwiftLint-Legacy/Source/swiftlint/main.swift:5:30 - line:18:1] RangeText="{
    let registry = CommandRegistry<CommandantError<()>>()
    registry.register(LintCommand())
    registry.register(AutoCorrectCommand())
    registry.register(AnalyzeCommand())
    registry.register(VersionCommand())
    registry.register(RulesCommand())
    registry.register(GenerateDocsCommand())
    registry.register(HelpCommand(registry: registry))

    registry.main(defaultVerb: LintCommand().verb) { error in
        queuedPrintError(String(describing: error))
    }
"
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x000000011352ba88 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 40
1  swift-frontend           0x0000000113529b78 llvm::sys::RunSignalHandlers() + 248
2  swift-frontend           0x000000011352c0fe SignalHandler(int) + 270
3  libsystem_platform.dylib 0x00007ff80c8d85ed _sigtramp + 29
4  libsystem_platform.dylib 000000000000000000 _sigtramp + 18446603370370333232
5  libsystem_c.dylib        0x00007ff80c7d1b45 abort + 123
6  swift-frontend           0x000000010c7ffad7 swift::DiagnosticHelper::Implementation::diagnoseFatalError(char const*, bool) + 599
7  swift-frontend           0x0000000113496c98 llvm::report_fatal_error(llvm::Twine const&, bool) + 344
8  swift-frontend           0x0000000113496b39 llvm::report_fatal_error(char const*, bool) + 41
9  swift-frontend           0x000000010d752df8 swift::LinearLifetimeChecker::ErrorBuilder::handleError(llvm::function_ref<void ()>&&, bool) const + 552
10 swift-frontend           0x000000010d75060e swift::LinearLifetimeChecker::checkValueImpl(swift::SILValue, llvm::ArrayRef<swift::Operand*>, llvm::ArrayRef<swift::Operand*>, swift::LinearLifetimeChecker::ErrorBuilder&, std::__1::optional<llvm::function_ref<void (swift::SILBasicBlock*)>>, std::__1::optional<llvm::function_ref<void (swift::Operand*)>>) + 2126
11 swift-frontend           0x000000010d751ab9 swift::LinearLifetimeChecker::checkValue(swift::SILValue, llvm::ArrayRef<swift::Operand*>, llvm::ArrayRef<swift::Operand*>, swift::LinearLifetimeChecker::ErrorBuilder&) + 73
12 swift-frontend           0x000000010d759cc5 swift::SILValueOwnershipChecker::check() + 725
13 swift-frontend           0x000000010d75c132 verifySILValueHelper(swift::SILFunction const*, swift::SILValue, swift::LinearLifetimeChecker::ErrorBuilder&, swift::DeadEndBlocks*, swift::GuaranteedPhiVerifier&) + 194
14 swift-frontend           0x000000010d75c57d swift::SILFunction::verifyOwnership(swift::DeadEndBlocks*) const + 717
15 swift-frontend           0x000000010d209fa6 (anonymous namespace)::CopyPropagation::run() + 8374
16 swift-frontend           0x000000010d123130 swift::SILPassManager::runPassOnFunction(unsigned int, swift::SILFunction*) + 1648
17 swift-frontend           0x000000010d124219 swift::SILPassManager::runFunctionPasses(unsigned int, unsigned int) + 1257
18 swift-frontend           0x000000010d120c98 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 72
19 swift-frontend           0x000000010d120c23 swift::ExecuteSILPipelineRequest::evaluate(swift::Evaluator&, swift::SILPipelineExecutionDescriptor) const + 51
20 swift-frontend           0x000000010d17bc0d swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 29
21 swift-frontend           0x000000010d13fa15 swift::ExecuteSILPipelineRequest::OutputType swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest, swift::ExecuteSILPipelineRequest::OutputType swift::evaluateOrFatal<swift::ExecuteSILPipelineRequest>(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()>(swift::ExecuteSILPipelineRequest const&, swift::ExecuteSILPipelineRequest::OutputType swift::evaluateOrFatal<swift::ExecuteSILPipelineRequest>(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()) + 181
22 swift-frontend           0x000000010d120eb0 swift::executePassPipelinePlan(swift::SILModule*, swift::SILPassPipelinePlan const&, bool, swift::irgen::IRGenModule*) + 64
23 swift-frontend           0x000000010d155723 swift::runSILOptimizationPasses(swift::SILModule&) + 163
24 swift-frontend           0x000000010c817a44 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 260
25 swift-frontend           0x000000010c57f980 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 800
26 swift-frontend           0x000000010c57f4c9 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 2409
27 swift-frontend           0x000000010c58cbbf withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 143
28 swift-frontend           0x000000010c581085 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 949
29 swift-frontend           0x000000010c5806ab swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2539
30 swift-frontend           0x000000010c311bd6 swift::mainEntry(int, char const**) + 2550
31 dyld                     0x00007ff80c55141f start + 1903

@augusto2112
Copy link
Contributor Author

@swift-ci test

Copy link
Contributor

@adrian-prantl adrian-prantl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, minor nits inside.

@augusto2112
Copy link
Contributor Author

@swift-ci test

@augusto2112
Copy link
Contributor Author

@augusto2112
Copy link
Contributor Author

1 similar comment
@augusto2112
Copy link
Contributor Author

@augusto2112
Copy link
Contributor Author

Emit an imported declaration for @_originallyDefinedIn under the
real module that these types live in.

This patch also changes the mangling for the debugger to respect
@_originallyDefinedIn, and fixes a bug where @_originallyDefinedIn
that should be ignored was still being used when mangling.

rdar://137146961
@augusto2112
Copy link
Contributor Author

3 similar comments
@augusto2112
Copy link
Contributor Author

@augusto2112
Copy link
Contributor Author

@augusto2112
Copy link
Contributor Author

@augusto2112
Copy link
Contributor Author

1 similar comment
@augusto2112
Copy link
Contributor Author

@augusto2112 augusto2112 merged commit dccc52d into swiftlang:main Dec 18, 2024
5 checks passed
Steelskin added a commit to Steelskin/swift that referenced this pull request Dec 20, 2024
…ned-in"

This reverts commit dccc52d, reversing
changes made to 2571e05.
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.

2 participants