[PATCH] D34487: Restrict the definition of loop preheader to avoid special blocks

Andy Kaylor via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 21 16:55:56 PDT 2017


andrew.w.kaylor created this revision.
Herald added a subscriber: mzolotukhin.

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.


Repository:
  rL LLVM

https://reviews.llvm.org/D34487

Files:
  include/llvm/Analysis/LoopInfoImpl.h
  include/llvm/CodeGen/MachineBasicBlock.h
  include/llvm/IR/BasicBlock.h
  lib/CodeGen/MachineBasicBlock.cpp
  lib/IR/BasicBlock.cpp
  test/Transforms/LoopRotate/catchret.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D34487.103492.patch
Type: text/x-patch
Size: 5104 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170621/c5c07713/attachment.bin>


More information about the llvm-commits mailing list