[PATCH] D70781: AMDGPU: Fix handling of infinite loops in fragment shaders

Connor Abbott via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 27 06:27:12 PST 2019


cwabbott created this revision.
cwabbott added reviewers: arsenm, nhaehnle.
Herald added subscribers: llvm-commits, hiraditya, t-tye, tpr, dstuttard, yaxunl, wdng, jvesely, kzhuravl.
Herald added a project: LLVM.

Due to the fact that kill is just a normal intrinsic, even though it's
supposed to terminate the thread, we can end up with provably infinite
loops that are actually supposed to end successfully. The
AMDGPUUnifyDivergentExitNodes pass breaks up these loops, but because
there's no obvious place to make the loop branch to, it just makes it
return immediately, which skips the exports that are supposed to happen
at the end and hangs the GPU if all the threads end up being killed.

While it would be nice if the fact that kill terminates the thread were
modeled in the IR, I think that the structurizer as-is would make a mess if we
did that when the kill is inside control flow. For now, we just add a null
export at the end to make sure that it always exports something, which fixes
the immediate problem without penalizing the more common case. This means that
we sometimes do two "done" exports when only some of the threads enter the
discard loop, but from tests the hardware seems ok with that.

This fixes dEQP-VK.graphicsfuzz.while-inside-switch with radv.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D70781

Files:
  llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp
  llvm/test/CodeGen/AMDGPU/kill-infinite-loop.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D70781.231238.patch
Type: text/x-patch
Size: 5902 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20191127/2b6c68bf/attachment.bin>


More information about the llvm-commits mailing list