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

Noah Goldstein via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 7 01:34:22 PDT 2023


goldstein.w.n added a comment.

In D152241#4402421 <https://reviews.llvm.org/D152241#4402421>, @nikic wrote:

> Using getUnderlyingObject() here is not quite right: The underlying object is a pure provenance notion, while icmp is a pure address comparison. What we need here is that the icmp can be expressed as `Base + Offset1 == Base + Offset2`. This is *nearly* what getUnderlyingObject() does in practice, but not quite.
>
> In particular, getUnderlyingObject() can also look through ptrmask intrinsics. However, `ptrmask(P, M) == P` clearly leaks bits of the pointers.

The case being because depending on `M` is indicates which bits in `P` are zero?
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).

> I think you'll have to implement a separate utility here that only looks through GEP + casts, but not things like ptrmask.





================
Comment at: llvm/lib/Analysis/CaptureTracking.cpp:416
+               getUnderlyingObjectLookThrough(I->getOperand(OtherIdx)))
+      // Pointers that are comparisons against the same object to do not
+      // capture.
----------------
think the "to" is extra.


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