Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #65195.
Hoisting a poison is safe only when it doesn't introduce more UB.
Currently, I'm just preventing preserving metadata like range.
I'm going to backport to LLVM.
17, so I don't want to introduce too many changes.
I think there are two approaches to restoring this range:
a. Do a may analysis using dataflow. However, in the issue, we have to consider both the result of the instruction and the operation value propagation. This can make the analysis complicated or useless.
b. Introduces a new valid scope for the metadata record
range
. This way we can reasonably determine whether UB can be triggered.I'm not sure which is better. But I tend to favor method B. From what I understand, we use UB for optimization. I think a poison that can't trigger a UB makes no sense.