[PATCH] D143129: [GVN] Do not propagate equalities for noalias pointers

Juneyoung Lee via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 10 09:06:11 PST 2023


aqjune added a subscriber: nlopes.
aqjune added a comment.

> The one case I'm probably worried about most are checks of the form %p == null, where replacing %p with null is not generally legal because it has nullary provenance. Replacing two arbitrary pointers likely isn't super important, but replacement with null might be.



> I was looking at https://llvm.org/devmtg/2018-04/slides/Lopes-Sbirlea-Pointers,%20Alias%20and%20ModRef%20Analyses.pdf page 15, which says that replacement with null ptr is safe. So I did two runs, one where we do pointer replacement only when they have same underlying objects, and the another where we also replace pointers with null.

The validity of this transformation depends on the definition of a null pointer which is in a gray area.
The slide is based on the following memory model: (1) we can safely replace `p` with `inttoptr (ptrtoint p)`. (2) null pointer is equivalent to `inttoptr 0` (or `inttoptr c` for some special, fixed constant).
In this model, replacing p with null is fine.

I think we can talk about this in the LLVM discourse group. The numbers look informative and people would like to see them & suggest their ideas.


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

https://reviews.llvm.org/D143129



More information about the llvm-commits mailing list