[PM] Sink an LCSSA preservation assert from the LoopSimplify pass into
authorChandler Carruth <chandlerc@gmail.com>
Sat, 21 Jan 2017 04:16:53 +0000 (04:16 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Sat, 21 Jan 2017 04:16:53 +0000 (04:16 +0000)
commit7fd29cef421c0dc0c52279ebd3f0fbbb2e534c35
tree35d35d46c7a071946c7f592eecc724edb788b4c3
parent17350de1cab38961ae3636f01b2bcad4c6d0d278
[PM] Sink an LCSSA preservation assert from the LoopSimplify pass into
the library routine shared with the new PM and other code.

This assert checks that when LCSSA preservation is requested we start in
LCSSA form. Without this early assert, given *very* complex test cases
we can hit an assert or crash much later on when trying to preserve
LCSSA.

The new PM's loop simplify doesn't need to (and indeed can't) preserve
LCSSA as the new PM doesn't deal in transforms in the dependency graph.
But we asked the library to and shockingly, this didn't work very well!
Stop doing that. Now the assert will tell us immediately with existing
test cases. Before this, it took a pretty convoluted input to trigger
this.

However, sinking the assert also found a bug in LoopUnroll where we
asked simplifyLoop to preserve LCSSA *right before we reform it*. That's
kinda silly and unsurprising that it wasn't available. =D Stop doing
that too.

We also would assert that the unrolled loop was in LCSSA even if
preserving LCSSA was never requested! I don't have a test case or
anything here. I spotted it by inspection and it seems quite obvious. No
logic change anyways, that's just avoiding a spurrious assert.

llvm-svn: 292710
llvm/lib/Transforms/Utils/LoopSimplify.cpp
llvm/lib/Transforms/Utils/LoopUnroll.cpp