This will avoid segmentation fault to access the loop fields.
Details
Diff Detail
Event Timeline
The comments I think are copied from another test and probably not relevant for this, so should be removed.
The test function should also have a better name about the situation with unreachables
The test also should run the IR pass itself and check for the inserted control flow intrinsics
For this patch, we give up "HandleLoop" if there is no loop. So I am not sure what to check for the inserted intrinsics.
Without the patch, there will be segfault.
Update based on review comments:
- remove irrelevant comment;
- add OPT test to check the llvm.amdgcn.loop intrinsic is not added;
- add test that uses "ret" instruction instead of "unreachable".
LGTM, though it might be a good idea to add some code before unreachable / ret in this one too in case something decides that it can de-duplicate blocks someday
Patch committed to LLVM trunk
commit 539fec5dc2cb0b0931ab47f4b705419e8f18bd34
Author: Changpeng Fang <changpeng.fang@gmail.com>
Date: Thu Jul 28 23:01:45 2016 +0000
AMDGPU/SI: Don't handle a loop if there is no loop at all for a terminator BB. Differential Revision: http://reviews.llvm.org/D22021 Reviewed by: arsenm git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@277073 91177308-0d34-0410-b5e6-96231b3b80d8