This is an archive of the discontinued LLVM Phabricator instance.

AMDGPU: Fix crash when folding immediates into multiple uses
ClosedPublic

Authored by nhaehnle on Jul 14 2017, 6:57 AM.

Details

Summary

When an immediate is folded by constant folding, we re-scan the entire
use list for two reasons:

  1. The constant folding may have created a new use of the same reg.
  2. The constant folding may have removed an additional use in the list we're currently traversing (e.g., constant folding an S_ADD_I32 c, c).

However, this could previously lead to a crash when an unrelated use was
added twice into the FoldList. Since we re-scan the whole list anyway, we
might as well just clear the FoldList again before we do so.

Using a MIR test to show this because real code seems to trigger the issue
only in connection with some really subtle control flow structures.

Fixes GL45-CTS.shading_language_420pack.binding_images on gfx9.

Event Timeline

nhaehnle created this revision.Jul 14 2017, 6:57 AM
arsenm accepted this revision.Jul 14 2017, 10:05 AM

LGTM but test can be reduced a little bit

test/CodeGen/MIR/AMDGPU/fold-multiple.mir
34–47

You can delete this

56

You can remove the MMO, the name of the block and then you can remove the IR section

This revision is now accepted and ready to land.Jul 14 2017, 10:05 AM
This revision was automatically updated to reflect the committed changes.