[PATCH] D81310: Stabilize alloca slices sort in SROA

Stanislav Mekhanoshin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 5 15:11:04 PDT 2020


rampitec created this revision.
rampitec added reviewers: arsenm, chandlerc.
Herald added subscribers: hiraditya, wdng.
Herald added a project: LLVM.

Slice::operator<() has a non-deterministic behavior. If we have
identical slices comparison will depend on the order or operands.
Normally that does not result in unstable compilation results
because the order in which slices are inserted into the vector
is deterministic and llvm::sort() normally behaves as a stable
sort, although that is not guaranteed.

However, there is test option -sroa-random-shuffle-slices which
is used to check exactly this aspect. The vector is first randomly
shuffled and then sorted. The same shuffling happens without this
option under expensive llvm checks.

I have managed to write a test which has hit this problem.

There are no fields in the Slice class to resolve the instability.
We only have offsets, IsSplittable and Use, but neither Use nor
User have anything suitable for predictable comparison. Therefore
I had to add a new Ordinal field for this purpose only.


https://reviews.llvm.org/D81310

Files:
  llvm/lib/Transforms/Scalar/SROA.cpp
  llvm/test/Transforms/SROA/phi-gep.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81310.268949.patch
Type: text/x-patch
Size: 8738 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200605/297a052a/attachment.bin>


More information about the llvm-commits mailing list