[llvm] [polly] [InstSimplify] Fix incorrect poison propagation when folding phi (PR #96631)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 25 11:37:18 PDT 2024


nikic wrote:

@dtcxzyw Thanks! I think the main two takeaways are:

1. I suspect that we need a `nopoison` attribute (and I guess `!nopoison`) metadata. The current noundef is too strong, and in Rust often cannot be applied because e.g. parts of enums are only conditionally initialized. However, I believe that all frontend-generated arguments/returns/loads can be nopoison, because Rust does not expose poison in its semantics (and I think this holds for pretty much all other frontends as well). Having nopoison would mean that pretty much all "roots" can be known not to be poison. Once undef is removed (or at least not allowed to be referenced from inside functions) we would drop noundef and only have nopoison.
2. We should probably be folding `select c, undef, x` to `freeze(x)` if we can't determine that x is non-poison. Otherwise we may carry a complex select condition around all the way to the backend. Having the freeze is not ideal, but I think it's the better tradeoff. (The same kind of applies to phis after this change, but it's probably less important there because the condition is still used by the branch.)

https://github.com/llvm/llvm-project/pull/96631


More information about the llvm-commits mailing list