Skip to content

[embedded] Avoid materializing generic functions for debuginfo purposes in embedded Swift #69682

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
Nov 7, 2023

Conversation

kubamracek
Copy link
Contributor

The attached testcase triggers a crash in embedded Swift mode because debuginfo ends up referencing a generic function (in the "inlined from" debuginfo data). This generic function is otherwise unused (and harmless in embedded Swift mode), but debuginfo generation will actually try to materialize it. Let's avoid that in embedded Swift.

Assertion failed: (!f->isGeneric()), function addLazyFunction, file GenDecl.cpp, line 1567.
...
3.	While evaluating request IRGenRequest(IR Generation for module main)
4.	While emitting IR SIL function "@$s4main15GenericSubClassC3fooyyFyycfU_AA11ImplementorC_Tg5".
 for expression at [/Users/kuba/swift-github-main/swift/test/embedded/generic-classes-debuginfo.swift:33:13 - line:33:33] RangeText="{ self.p.protofoo() "
...
 #8 0x00000001011c3090 swift::irgen::IRGenerator::addLazyFunction(swift::SILFunction*)
 #9 0x00000001011c54c4 swift::irgen::IRGenModule::getAddrOfSILFunction(swift::SILFunction*, swift::ForDefinition_t, bool, bool)
#10 0x00000001012cd910 (anonymous namespace)::IRGenDebugInfoImpl::getOrCreateScope(swift::SILDebugScope const*)
#11 0x00000001012d3cd0 (anonymous namespace)::IRGenDebugInfoImpl::getOrCreateContext(swift::DeclContext*)
#12 0x00000001012cdfa0 (anonymous namespace)::IRGenDebugInfoImpl::emitFunction(swift::SILDebugScope const*, llvm::Function*, swift::SILFunctionTypeRepresentation, swift::SILType, swift::DeclContext*, llvm::StringRef)
#13 0x00000001012cebc0 (anonymous namespace)::IRGenDebugInfoImpl::emitFunction(swift::SILFunction&, llvm::Function*)
#14 0x000000010130829c (anonymous namespace)::IRGenSILFunction::emitSILFunction()
#15 0x0000000101307a0c swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*)
#16 0x00000001011c0f4c swift::irgen::IRGenerator::emitGlobalTopLevel(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&)
#17 0x00000001012c0d68 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const

@kubamracek kubamracek added the embedded Embedded Swift label Nov 6, 2023
Copy link
Contributor

@eeckstein eeckstein left a comment

Choose a reason for hiding this comment

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

lgtm!

@kubamracek
Copy link
Contributor Author

@swift-ci please test

@kubamracek
Copy link
Contributor Author

@swift-ci please smoke test macOS platform

@kubamracek
Copy link
Contributor Author

@swift-ci please test macOS platform

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
embedded Embedded Swift
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants