[PATCH] D71960: [Attributor] AAUndefinedBehavior: Use AAValueSimplify in memory accessing instructions.

Stefanos Baziotis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 13 18:55:22 PST 2020


baziotis added a comment.

In D71960#1873456 <https://reviews.llvm.org/D71960#1873456>, @jdoerfert wrote:

> In D71960#1873401 <https://reviews.llvm.org/D71960#1873401>, @baziotis wrote:
>
> > - Added tests
>
>
> All the tests have FIXMEs, right? Can you explain why they don't work yet?


Yes. For most tests the reason is that `AAValueSimplify` doesn't give a known value. In other words, in `stopOnUndefOrAssumed()`, we don't get past the first if (`if (!ValueSimplifyAA.isKnown())`).

Seeing that again though, returning from this `if` effectively means that the instruction remains assumed UB.
The whole procedure ends with the instruction still assumed UB. So, doesn't that fixpoint to known UB actually ?

But then, check this:

  define internal i32* @ret_null(i32* %A) {
    ret i32* %A
  }
  
  define void @load_null_propagated(i32* %A) {
    %ptr = call i32* @ret_null(i32* %A)
    %a = load i32, i32* %ptr
    ret void
  }

The output is (same with AAUB disabled):

  define void @load_null_propagated(i32* nocapture nofree readonly %A) #0 {
    %a = load i32, i32* undef
    ret void
  }

First of all, even if what I said above is correct, `AAValueSimplify` still gives us no value for the pointer which keeps an actually non-UB instruction to assumed till the end.
But then second, isn't that output wrong in general ?

> We also need tests that didn't work before but now, maybe just copies of the one you repaired but without the "repair" part.

Hmm, yes, that should be feasible to do in `2008-07-02-array-indexing.ll` and `PR26044.ll`. Guessing what else this patch could "repair" / improve and making new tests is more challenging.


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

https://reviews.llvm.org/D71960





More information about the llvm-commits mailing list