[Scalarizer] Fix a non-deterministic scatter order problem
authorBjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Sun, 19 Apr 2020 10:56:16 +0000 (12:56 +0200)
committerBjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Mon, 20 Apr 2020 14:05:33 +0000 (16:05 +0200)
commita8a31fdd80ccd5c9939ac41a8751ab3e7b8e146d
treecb35c3d699e6c2f3de4f3a482577a748ff07933b
parent515020c091e74723ee0876229890d71a8aa79702
[Scalarizer] Fix a non-deterministic scatter order problem

Summary:
The indexing operator in Scatterer may result in building new
instructions. When using multiple such operators in a function
argument list the order in which we build instructions depend on
argument evaluation order (which is undefined in C++).
This patch avoid such problems by expanding the components using
the [] operator prior to the function call.

Problem was seen when comparing output, while builing LLVM with
different compilers (clang vs gcc).

Reviewers: foad, cameron.mcinally, uabelho

Reviewed By: foad

Subscribers: hiraditya, mgrang, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D78455
llvm/lib/Transforms/Scalar/Scalarizer.cpp
llvm/test/Transforms/Scalarizer/scatter-order.ll [new file with mode: 0644]