[LoopSink] Make the enforcement of determinism deterministic.
authorBenjamin Kramer <benny.kra@googlemail.com>
Fri, 6 Jul 2018 14:20:58 +0000 (14:20 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Fri, 6 Jul 2018 14:20:58 +0000 (14:20 +0000)
commit3687ac52a9fd6789a3088fd3eeca1e47ae04bfff
tree0b1e1d8da8b46440824a79749c748785f5345c21
parentb1711b28f7a894dded4f775d8919a21601a030f2
[LoopSink] Make the enforcement of determinism deterministic.

LoopBlockNumber is a DenseMap<BasicBlock*, int>, comparing the result of
find() will compare a pair<BasicBlock*, int>. That's of course depending
on pointer ordering which varies from run to run. Reverse iteration
doesn't find this because we're copying to a vector first.

This bug has been there since 2016 but only recently showed up on clang
selfhost with FDO and ThinLTO, which is also why I didn't manage to get
a reasonable test case for this. Add an assert that would've caught
this.

llvm-svn: 336439
llvm/lib/Transforms/Scalar/LoopSink.cpp