Skip to content

Conversation

@tekknolagi
Copy link
Contributor

Add is_elidable field that signals that there would be no discernible
effect if the call to the method were removed. The default is false.

@matzbot matzbot requested a review from a team May 16, 2025 15:58
/// What Type the C function returns
pub return_type: Type,
/// Whether it's legal to remove the call if the result is unused
pub is_elidable: bool,
Copy link
Member

Choose a reason for hiding this comment

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

"is elidable" doesn't seem to explain the actual property that makes it elidable, so things like "pure" or "side effect free" might clarify the nature better. But I'm sure sure if I like them more than "is elidable" 🤷‍♂️

Copy link
Member

Choose a reason for hiding this comment

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

It can be just elidable though. leaf is not is_leaf. annotate!(..., elidable); feels more fluent to me. But it could be just me.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It's kind of hard to describe because these kinds of operations could have side effects such as GC but we might not care. For example, allocating a 1 B element array that is unused might cause an OOM exception in the interpreter but might get deleted as unused by the compiler. I will think about this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ok, here's another side effect: a hypothetical HIR instruction that does a method lookup. This is actually a complicated operation, potentially, if it uses the global method lookup cache. This is a subtle side effect that we might not care about from a "should we keep it around" perspective but does require special care in code generation.

@tekknolagi tekknolagi changed the title Allow DCE to remove some CCalls ZJIT: Allow DCE to remove some CCalls May 19, 2025
Add `elidable` field that signals that there would be no discernible
effect if the call to the method were removed. The default is false.
@k0kubun k0kubun merged commit b08e20d into ruby:master May 20, 2025
81 of 82 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