-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[DebugInfo] Fix infinite recursion when opaque return type is defined inside function returning it #81794
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
base: main
Are you sure you want to change the base?
Conversation
inside function returning it A stack overflow would happen when the compiler tried emitting debug info for a function whose opaque return type was declared inside the function itself. This fixes the issue by emitting a forward declaration for the function before emitting it. rdar://150313956
@swift-ci smoke test |
@@ -3201,6 +3204,11 @@ IRGenDebugInfoImpl::emitFunction(const SILDebugScope *DS, llvm::Function *Fn, | |||
Name = getName(DS->Loc); | |||
} | |||
|
|||
llvm::DISubprogram *ReplaceableType = DBuilder.createTempFunctionFwdDecl( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: as someone unfamiliar with this API, parameter comments could help contextualize the various constants that are being passed through. although i see that isn't universally done in this file.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks safe & correct, thanks!
@@ -3201,6 +3204,11 @@ IRGenDebugInfoImpl::emitFunction(const SILDebugScope *DS, llvm::Function *Fn, | |||
Name = getName(DS->Loc); | |||
} | |||
|
|||
llvm::DISubprogram *ReplaceableType = DBuilder.createTempFunctionFwdDecl( | |||
nullptr, Name, LinkageName, 0, 0, nullptr, 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, if you passed in the correct scope here instead of nullptr
— does that make the other change unnecessary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What do you mean? This is creating the temporary forward declaration so if we recurse back here we return it instead. If I passed the scope of the function when creating the temporary? What other change are you referring to?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In line 976 you are guarding against a DIScope with a null DIFile. I was wondering if that is because your temporary Subprogram (which is a DIScope) has a null DIFile.
A stack overflow would happen when the compiler tried emitting debug info for a function whose opaque return type was declared inside the function itself. This fixes the issue by emitting a forward declaration for the function before emitting it.
rdar://150313956