Skip to content
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

[CIR][TargetLowering] Fix use iteration #1162

Merged
merged 1 commit into from
Nov 25, 2024

Conversation

smeenai
Copy link
Collaborator

@smeenai smeenai commented Nov 25, 2024

Based on https://mlir.llvm.org/docs/Tutorials/UnderstandingTheIRStructure/#traversing-the-def-use-chains,
the users of an op are linked together in a doubly-linked list, so
replacing a user while iterating the users causes a use-after-free.
Store the users in a worklist and process them afterwards instead to
avoid this.

Based on https://mlir.llvm.org/docs/Tutorials/UnderstandingTheIRStructure/#traversing-the-def-use-chains,
the users of an op are linked together in a doubly-linked list, so
replacing a user while iterating the users causes a use-after-free.
Store the users in a worklist and process them afterwards instead to
avoid this.
Copy link
Member

@bcardosolopes bcardosolopes left a comment

Choose a reason for hiding this comment

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

Awesome!

@bcardosolopes bcardosolopes merged commit f00568c into llvm:main Nov 25, 2024
7 checks passed
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