[all-commits] [llvm/llvm-project] 0994c4: AMDGPU: Fix handling of infinite loops in fragment...

Connor Abbott via All-commits all-commits at lists.llvm.org
Wed Jan 29 06:29:20 PST 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 0994c485e61322a04e580d83617eab547292aba2
      https://github.com/llvm/llvm-project/commit/0994c485e61322a04e580d83617eab547292aba2
  Author: Connor Abbott <cwabbott0 at gmail.com>
  Date:   2020-01-29 (Wed, 29 Jan 2020)

  Changed paths:
    M llvm/lib/Target/AMDGPU/AMDGPUUnifyDivergentExitNodes.cpp
    A llvm/test/CodeGen/AMDGPU/kill-infinite-loop.ll

  Log Message:
  -----------
  AMDGPU: Fix handling of infinite loops in fragment shaders

Summary:
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.

Reviewers: arsenm, nhaehnle

Subscribers: kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D70781


  Commit: 323bfde20c5f3e63db3d6b385b394ed38542abe6
      https://github.com/llvm/llvm-project/commit/323bfde20c5f3e63db3d6b385b394ed38542abe6
  Author: Connor Abbott <cwabbott0 at gmail.com>
  Date:   2020-01-29 (Wed, 29 Jan 2020)

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

  Log Message:
  -----------
  AMDGPU: Fix AMDGPUUnifyDivergentExitNodes with no normal returns

Summary:
The code was assuming in a few places that if there was only one exit
from the function that it was a normal return, which is invalid. It
could be an infinite loop, in which case we still need to insert the
usual fake edge so that the null export happens. This fixes shaders that
end with an infinite loop that discards.

Reviewers: arsenm, nhaehnle, critson

Subscribers: kzhuravl, jvesely, wdng, yaxunl, dstuttard, tpr, t-tye, hiraditya, llvm-commits

Tags: #llvm

Differential Revision: https://reviews.llvm.org/D71192


Compare: https://github.com/llvm/llvm-project/compare/fce8983a3c03...323bfde20c5f


More information about the All-commits mailing list