This patch modifies the LoopBase::getLoopPreheader() so that it will not identify blocks as preheaders if instructions cannot legally be hoisted into the block. This currently just eliminates special Windows EH blocks to avoid hoisting instructions into funclets.
This change was motivated by a bug a found in loop rotate and the discussion in the comments of that bug (https://bugs.llvm.org/show_bug.cgi?id=33393).
Because getLoopPreheader() is in the LoopBase<BlockT*> template class and we can't examine terminator instructions from there I couldn't simply check the predecessor block's terminator for side effects as suggested. Looking at the uses of getLoopPreheader() it seemed that it is generally used to find a place to hoist instructions, and so I decided to add a method that would check for the legality of doing so.
nit, you can simplify return !isReturnBlock() && !hasEHPadSuccessors()