[PATCH] R600/SI: Fix assertion on infinite loops.
Tom Stellard
tom at stellard.net
Tue Feb 11 12:21:31 PST 2014
On Mon, Feb 03, 2014 at 05:30:04PM -0800, Matt Arsenault wrote:
> This isn't the most useful case to fix in the real world, but bugpoint runs into this.
LGTM.
>
> http://llvm-reviews.chandlerc.com/D2682
>
> Files:
> lib/Target/R600/SILowerControlFlow.cpp
> test/CodeGen/R600/infinite-loop.ll
>
> Index: lib/Target/R600/SILowerControlFlow.cpp
> ===================================================================
> --- lib/Target/R600/SILowerControlFlow.cpp
> +++ lib/Target/R600/SILowerControlFlow.cpp
> @@ -283,8 +283,10 @@
> }
>
> void SILowerControlFlowPass::Branch(MachineInstr &MI) {
> - assert(MI.getOperand(0).getMBB() == MI.getParent()->getNextNode());
> - MI.eraseFromParent();
> + if (MI.getOperand(0).getMBB() == MI.getParent()->getNextNode())
> + MI.eraseFromParent();
> +
> + // If these aren't equal, this is probably an infinite loop.
> }
>
> void SILowerControlFlowPass::Kill(MachineInstr &MI) {
> Index: test/CodeGen/R600/infinite-loop.ll
> ===================================================================
> --- /dev/null
> +++ test/CodeGen/R600/infinite-loop.ll
> @@ -0,0 +1,17 @@
> +; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI %s
> +
> +; SI-LABEL: @infinite_loop:
> +; SI: V_MOV_B32_e32 [[REG:v[0-9]+]], 999
> +; SI: BB0_1:
> +; SI: BUFFER_STORE_DWORD [[REG]]
> +; SI: S_WAITCNT vmcnt(0) expcnt(0)
> +; SI: S_BRANCH BB0_1
> +define void @infinite_loop(i32 addrspace(1)* %out) {
> +entry:
> + br label %for.body
> +
> +for.body: ; preds = %entry, %for.body
> + store i32 999, i32 addrspace(1)* %out, align 4
> + br label %for.body
> +}
> +
> Index: lib/Target/R600/SILowerControlFlow.cpp
> ===================================================================
> --- lib/Target/R600/SILowerControlFlow.cpp
> +++ lib/Target/R600/SILowerControlFlow.cpp
> @@ -283,8 +283,10 @@
> }
>
> void SILowerControlFlowPass::Branch(MachineInstr &MI) {
> - assert(MI.getOperand(0).getMBB() == MI.getParent()->getNextNode());
> - MI.eraseFromParent();
> + if (MI.getOperand(0).getMBB() == MI.getParent()->getNextNode())
> + MI.eraseFromParent();
> +
> + // If these aren't equal, this is probably an infinite loop.
> }
>
> void SILowerControlFlowPass::Kill(MachineInstr &MI) {
> Index: test/CodeGen/R600/infinite-loop.ll
> ===================================================================
> --- /dev/null
> +++ test/CodeGen/R600/infinite-loop.ll
> @@ -0,0 +1,17 @@
> +; RUN: llc -march=r600 -mcpu=SI -verify-machineinstrs < %s | FileCheck -check-prefix=SI %s
> +
> +; SI-LABEL: @infinite_loop:
> +; SI: V_MOV_B32_e32 [[REG:v[0-9]+]], 999
> +; SI: BB0_1:
> +; SI: BUFFER_STORE_DWORD [[REG]]
> +; SI: S_WAITCNT vmcnt(0) expcnt(0)
> +; SI: S_BRANCH BB0_1
> +define void @infinite_loop(i32 addrspace(1)* %out) {
> +entry:
> + br label %for.body
> +
> +for.body: ; preds = %entry, %for.body
> + store i32 999, i32 addrspace(1)* %out, align 4
> + br label %for.body
> +}
> +
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list