Fix possible infinite loop in shrink wrapping when searching for save/restore
authorKit Barton <kbarton@ca.ibm.com>
Thu, 6 Aug 2015 19:01:57 +0000 (19:01 +0000)
committerKit Barton <kbarton@ca.ibm.com>
Thu, 6 Aug 2015 19:01:57 +0000 (19:01 +0000)
commit1c618a4dd42bc51ff3893d95ff2c734175b2bf8c
treebeb41fe2fc218198798237f615c6afbbfaff8527
parentcfb2e818833832ffc47190132c39e06a8d22ea70
Fix possible infinite loop in shrink wrapping when searching for save/restore
points.

There is an infinite loop that can occur in Shrink Wrapping while searching
for the Save/Restore points.

Part of this search checks whether the save/restore points are located in
different loop nests and if so, uses the (post) dominator trees to find the
immediate (post) dominator blocks. However, if the current block does not have
any immediate (post) dominators then this search will result in an infinite
loop. This can occur in code containing an infinite loop.

The modification checks whether the immediate (post) dominator is different from
the current save/restore block. If it is not, then the search terminates and the
current location is not considered as a valid save/restore point for shrink wrapping.

Phabricator: http://reviews.llvm.org/D11607

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@244247 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/ShrinkWrap.cpp
test/CodeGen/AArch64/arm64-shrink-wrapping.ll
test/CodeGen/ARM/arm-shrink-wrapping.ll
test/CodeGen/X86/x86-shrink-wrapping.ll