-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Fix a use-after-free in MandatoryInlining #35037
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
Conversation
@swift-ci test |
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 is good to fix the issue.
Though, I have some comments (you can address them in a follow-up commit if you like).
Also, you should add a test.
@@ -481,6 +481,12 @@ class ClosureCleanup { | |||
if (!operandVal->getType().is<SILFunctionType>()) | |||
continue; | |||
|
|||
// Skip debug instructions |
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 check should be done at the function entry.
Can you add a bit more information in the comment? E.g. Add the info what you wrote in the PR description.
Also, you should mention that the special handling of debug instruction is done in eraseFromParentWithDebugInsts.
77b7839
to
2986115
Compare
In recordDeadFunction, we look at operands of an instruction to be deleted, and add back the defining instruction of the operands to the worklist. This works in general when we are deleting dead instructions recursively. But we also consider, an instruction with only debug uses as dead. So when we are deleting a debug instruction, we may have already deleted its operand's defining instruction. So it would be incorrect to add it to the worklist.
2986115
to
0c25245
Compare
@swift-ci smoke test and merge |
Thanks @eeckstein . I'll add the test you wrote in a follow on commit. |
* 'main' of github.com:apple/swift: Add test for swiftlang#35037
In recordDeadFunction, we look at operands of an instruction to be deleted,
and add back the defining instruction of the operands to the worklist.
This works in general when we are deleting dead instructions
recursively.
But we also consider, an instruction with only debug uses as dead. So
when we are deleting a debug instruction, we may have already deleted
its operand's defining instruction. So it would be incorrect to add it
to the worklist.
Fixes rdar://72029485