[all-commits] [llvm/llvm-project] c81926: [Attributor] Improve the Attributor::getAssumedCon...

Johannes Doerfert via All-commits all-commits at lists.llvm.org
Wed Jul 21 22:08:28 PDT 2021


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: c819266ecc8fa12e0d567be6b4dd7ea9c4eede87
      https://github.com/llvm/llvm-project/commit/c819266ecc8fa12e0d567be6b4dd7ea9c4eede87
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2021-07-22 (Thu, 22 Jul 2021)

  Changed paths:
    M llvm/include/llvm/Transforms/IPO/Attributor.h
    M llvm/lib/Transforms/IPO/Attributor.cpp

  Log Message:
  -----------
  [Attributor] Improve the Attributor::getAssumedConstant interface

Similar to Attributor::getAssumedSimplified we need to allow IRPs
directly to get the right simplification callback (and context).


  Commit: 94d3b59c563c077df560401945f32c55f7783e4c
      https://github.com/llvm/llvm-project/commit/94d3b59c563c077df560401945f32c55f7783e4c
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2021-07-22 (Thu, 22 Jul 2021)

  Changed paths:
    M llvm/include/llvm/Transforms/IPO/Attributor.h
    M llvm/lib/Transforms/IPO/Attributor.cpp
    M llvm/lib/Transforms/IPO/AttributorAttributes.cpp
    M llvm/test/Transforms/Attributor/memory_locations.ll
    M llvm/test/Transforms/Attributor/value-simplify-instances.ll

  Log Message:
  -----------
  [Attributor][FIX] Do not introduce multiple instances of SSA values

If we have a recursive function we could create multiple instantiations
of an SSA value, one per recursive invocation of the function. This is a
problem as we use SSA value equality in various places. The basic idea
follows from this test:

```
static int r(int c, int *a) {
  int X;
  return c ? r(false, &X) : a == &X;
}

int test(int c) {
  return r(c, undef);
}
```

If we look through the argument `a` we will end up with `X`. Using SSA
value equality we will fold `a == &X` to true and return true even
though it should have been false because `a` and `&X` are from different
instantiations of the function.

Various tests for this  have been placed in value-simplify-instances.ll
and this commit fixes them all by avoiding to produce simplified values
that could be non-unique at runtime. Thus, the result of a simplify
value call will always be unique at runtime or the original value, both
do not allow to accidentally compare two instances of a value with each
other and conclude they are equal statically (pointer equivalence) while
they are unequal at runtime.


  Commit: 0c0eb76782d5224b8d81a5afbb9a152bcf7c94c7
      https://github.com/llvm/llvm-project/commit/0c0eb76782d5224b8d81a5afbb9a152bcf7c94c7
  Author: Johannes Doerfert <johannes at jdoerfert.de>
  Date:   2021-07-22 (Thu, 22 Jul 2021)

  Changed paths:
    M llvm/lib/Transforms/IPO/Attributor.cpp

  Log Message:
  -----------
  [Attributor][FIX] Improve call graph updating

If we remove a non-intrinsic instruction we need to tell the (old) call
graph about it. This caused problems with some features down the line as
they allowed to removed calls more aggressively.


Compare: https://github.com/llvm/llvm-project/compare/8d86562e5f1f...0c0eb76782d5


More information about the All-commits mailing list