[PATCH] D114988: [IR] `GetElementPtrInst`: per-index `inrange` support

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 3 15:51:23 PST 2021


efriedma added a comment.

Consider the following:

  struct S {
      int a[3], b[3], c[3];
  };
  
  int foo(S* s) {
    return &s.a[3] == &s.b[0];
  }

The C standard says this returns 1; if you lower the address computation using inrange, it returns poison. I think?  Maybe you can apply inrange markings in some cases, e.g. you can be more aggressive if you prove the address is used by a load/store operations.  But it's not trivial.

Also, it's not obvious inrange is sound; nobody has tried to formally model the pointer provenance or pointer comparison rules specified for inrange.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D114988



More information about the llvm-commits mailing list