[all-commits] [llvm/llvm-project] d8cd7f: AlignmentFromAssumptions should only track pointer...

alex-t via All-commits all-commits at lists.llvm.org
Thu Dec 7 08:35:48 PST 2023


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: d8cd7fc1f404161f9ec378a1cf3c52f8b8e9beca
      https://github.com/llvm/llvm-project/commit/d8cd7fc1f404161f9ec378a1cf3c52f8b8e9beca
  Author: alex-t <alex-t at users.noreply.github.com>
  Date:   2023-12-07 (Thu, 07 Dec 2023)

  Changed paths:
    M llvm/lib/Transforms/Scalar/AlignmentFromAssumptions.cpp
    A llvm/test/Transforms/AlignmentFromAssumptions/alignment-from-assumptions-track-users.ll

  Log Message:
  -----------
  AlignmentFromAssumptions should only track pointer operand users (#73370)

AlignmentFromAssumptions uses SCEV to update the load/store alignment.
It tracks down the use-def chains for the pointer which it takes from
the assumption cache until it reaches the load or store instruction. It
mistakenly adds to the worklist the users of the load result
irrespective of the fact that the load result has no connection with the
original pointer, moreover, it is not a pointer at all in most cases.
Thus the def-use chain contains irrelevant load users. When it is a
store instruction the algorithm attempts to adjust its alignment to the
alignment of the original pointer. The problem appears when the load and
store memory operand pointers belong to different address spaces and
possibly have different sizes.
The 4bf015c035e4e5b63c7222dfb15ff274a5ed905c was an attempt to address a
similar problem. The truncation or zero extension was added to make
pointers the same size. That looks strange to me because the zero
extension of the pointer is not legal. The test in the
4bf015c035e4e5b63c7222dfb15ff274a5ed905c does not work any longer as for
the explicit address spaces conversion the addrspacecast is generated.
Summarize:
1. For the alloca to global address spaces conversion addrspacecasts are
used, so the code added by the 4bf015c035e4e5b63c7222dfb15ff274a5ed905c
is no longer functional.
2. The AlignmentFromAssumptions algorithm should not add the load users
to the worklist as they have nothing to do with the original pointer.
3. Instead we only track users that are: GetelementPtrIns, PHINodes.




More information about the All-commits mailing list