When all else fails, use range metadata to constrain the result of loads and calls. It should also be possible to use !nonnull, but that would require some general support for inequalities in SCCP first.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
LGTM, thanks.
It should also be possible to use !nonnull
using ValueLattice::getNot/markNotConstant should possibly just work? For icmps we use ValueLattice's helpers, they should be able to deal with it, unless we bail out for pointers somewhere in SCCP.
llvm/lib/Transforms/Scalar/SCCP.cpp | ||
---|---|---|
1107 | I think we have something similar in LVI. Might be good to move the common logic to ValueLattice | |
1121 | For volatile loads, I think we could still use the range info if present? We are just not allowed to remove the volatile operation, right? |
llvm/lib/Transforms/Scalar/SCCP.cpp | ||
---|---|---|
1121 | This would be safe. I briefly tried this, but found that SCCP would zap the volatile load, because it only uses isSafeToRemove() to determine whether instructions can be dropped. We would have to replace that with something stronger, like isInstructionTriviallyDead(). Do you think that would be worthwhile? |
I think we have something similar in LVI. Might be good to move the common logic to ValueLattice