[PATCH] D97665: [InstSimplify] Don't fold comparisons of non-inbounds GEPs

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 3 17:33:15 PST 2021


aqjune added a comment.

I don't have a clear model for the semantics of pointer comparison ATM; Pointer comparison *sometimes* needs to take provenance into consideration because LLVM folds `p1 == p2` where p1 and p2 are pointing to two different zero-size objects having the same address into false.
Also, considering provenance into account allows aggressively folding pointer comparisons. It isn't clear how *frequently* the provenance should be considered.

But, I'm rather curious about how the miscompilation happened from this optimization. A gep with such offset isn't common, unless a programmer writes a code that subtracts a pointer from null (which is already fishy)?
It would be great if I can see the input that causes miscompilation.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97665/new/

https://reviews.llvm.org/D97665



More information about the llvm-commits mailing list