[PATCH] D152241: [CaptureTracking] Do not capture equality compares of same object

Joshua Cao via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sat Jun 10 17:04:00 PDT 2023


caojoshua added a comment.

> If so then I think you can only do this for equality comparisons, otherwise something like:
> Base + Offset1 < Base + Offset2 can probably end up leaking some bits (depending on what is known
> about Offset1/Offset2) because of overflows.
> If that is a concern then you need to also ensure the ICmp is equality (its unchecked at the moment).

Thats a great point. I added a check to make sure its only equality comparisons.

Does not have to be part of this patch, but could we extend this to cover non-equality comparisons if all the GEPs are inbounds? From https://llvm.org/docs/LangRef.html#id234, inbounds GEPs are poison if there is wrapping

  The multiplication of an index by the type size does not wrap the pointer index type in a signed sense (nsw).
  The successive addition of offsets (without adding the base address) does not wrap the pointer index type in a signed sense (nsw).
  The successive addition of the current address, interpreted as an unsigned number, and an offset, interpreted as a signed number, does not wrap the unsigned address space and remains in bounds of the allocated object. As a corollary, if the added offset is non-negative, the addition does not wrap in an unsigned sense (nuw).


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D152241



More information about the llvm-commits mailing list