This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU/SI: Don't handle a loop if there is no loop at all for a terminator BB.
ClosedPublic

Authored by cfang on Jul 5 2016, 3:01 PM.

Details

Summary

This will avoid segmentation fault to access the loop fields.

Diff Detail

Event Timeline

cfang updated this revision to Diff 62796.Jul 5 2016, 3:01 PM
cfang retitled this revision from to AMDGPU/SI: Don't handle a loop if there is no loop at all for a terminator BB..
cfang updated this object.
cfang added reviewers: arsenm, tstellarAMD.
cfang added subscribers: arsenm, llvm-commits.
arsenm edited edge metadata.Jul 5 2016, 3:57 PM

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

arsenm added a comment.Jul 5 2016, 3:58 PM

The test also should run the IR pass itself and check for the inserted control flow intrinsics

arsenm added a comment.Jul 6 2016, 9:19 AM

Can you also add a version of the test that uses ret instead of unreachable?

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.

cfang updated this revision to Diff 64773.Jul 20 2016, 3:00 PM
cfang edited edge metadata.

Update based on review comments:

  1. remove irrelevant comment;
  2. add OPT test to check the llvm.amdgcn.loop intrinsic is not added;
  3. 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

cfang added a comment.Aug 11 2016, 2:42 PM

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
arsenm accepted this revision.Mar 30 2017, 10:35 AM
This revision is now accepted and ready to land.Mar 30 2017, 10:35 AM
arsenm closed this revision.Mar 30 2017, 10:35 AM