Skip to content

[CIR] Avoid unnecessary type cache clearing with Enum type completion #1673

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
Jun 10, 2025

Conversation

andykaylor
Copy link
Collaborator

When we process a completed Enum type, we were checking to see if the completed type was in the type cache and clearing the cache if the completed and converted underlying type for the enum doesn't pass an isInteger(32) check. Unfortunately, this checks to see if the type is the MLIR builtin 32-bit integer type, whereas it will always be a CIR integer type, so the check always fails.

I don't believe there can ever be a case where the forward declared type for the enum doesn't match the completed type, so we should never need to clear the cache. This change replaces the previous check with an assert that compares the actual completed type to the cached type.

When we process a completed Enum type, we were checking to see if the type
was in the type cache and clearing the cache if the mapped type for the
enum didn't pass an isInteger(32) check. Unfortunately, this checks to
see if the type is the MLIR builtin 32-bit integer type, whereas the
type we actually use as a default for forward-declared enums is a CIR
integer type, so the check always failed.

I don't believe there can ever be a case where the forward declared type
for the enum doesn't match the completed type, so we should never need
to clear the cache. This change replaces the previous check with an
assert that compares the actual completed type to the cached type.
@andykaylor
Copy link
Collaborator Author

This backports a change that was committed upstream here: llvm/llvm-project#143176

@xlauko xlauko self-requested a review June 10, 2025 15:09
Copy link
Collaborator

@xlauko xlauko left a comment

Choose a reason for hiding this comment

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

lgtm

@andykaylor andykaylor merged commit 25a9b13 into llvm:main Jun 10, 2025
10 checks passed
@andykaylor andykaylor deleted the cir-enum-tag branch June 10, 2025 18:12
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