This is an archive of the discontinued LLVM Phabricator instance.

[Scalarizer] Fix a non-deterministic scatter order problem
ClosedPublic

Authored by bjope on Apr 19 2020, 9:14 AM.

Details

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).

Diff Detail

Event Timeline

bjope created this revision.Apr 19 2020, 9:14 AM
Herald added a project: Restricted Project. · View Herald TranscriptApr 19 2020, 9:14 AM
foad accepted this revision.Apr 20 2020, 1:53 AM

LGTM.

Out of curiosity, why are you running the scalarizer? I thought most targets didn't use it.

This revision is now accepted and ready to land.Apr 20 2020, 1:53 AM
bjope added a comment.Apr 20 2020, 2:52 AM

LGTM.

Out of curiosity, why are you running the scalarizer? I thought most targets didn't use it.

We still use the scalarizer downstream, partly due to historical reasons. Nowadays I don't think we depend heavily on the scalarize (SelectionDAG will manage to do the business), but last time I tried to disable it I noticed some regressions. If I remember correctly it was due to some pre-isel-rewrites not triggering the same way when delaying the scalarization until isel (I think it was something that wasn't hoisted out of a loop so the penalty could not be ignored).

Thanks for the review!

This revision was automatically updated to reflect the committed changes.