[clang] [llvm] [DropUnnecessaryAssumes] Add pass for dropping assumes (PR #159403)
Nikita Popov via cfe-commits
cfe-commits at lists.llvm.org
Thu Sep 18 01:50:15 PDT 2025
nikic wrote:
> Do you think that this pass in the future can be a good place for dropping assumes by setting eg. ranges to arguments something similar to
>
> https://github.com/llvm/llvm-project/blob/6af5b41e4b4e303589ff709efaf783828dc3f75a/llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp#L3369-L3384
>
> I have tried to add handling for ranges there but there was regressions due to new uses after inlining
I think that ideally we would do this in InstCombine, and then materialize the assume again if the instruction/function the metadata/attribute was attached to gets removed. We do this for nonnull is SROA: https://github.com/llvm/llvm-project/blob/efa7385831503b38b45f8b4eca3e21ba7a261097/llvm/lib/Transforms/Utils/PromoteMemoryToRegister.cpp#L461-L492 But haven't extended this further due to the usual problem where assumes interfere too much with other optimizations for this to be overall worthwhile.
I hope that more aggressively dropping useless assumes will make this approach more viable...
https://github.com/llvm/llvm-project/pull/159403
More information about the cfe-commits
mailing list