Skip to content

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
terapines-osc-cir pushed a commit to Terapines/clangir that referenced this pull request Sep 2, 2025
…llvm#1673)

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.
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