diff options
author | Marek Olsak <marek.olsak@amd.com> | 2016-03-14 15:57:14 +0000 |
---|---|---|
committer | Marek Olsak <marek.olsak@amd.com> | 2016-03-14 15:57:14 +0000 |
commit | ed2213e6efc1cc71a323f49585e859d6e41853ed (patch) | |
tree | 17f1b4f4eec5df672bec4ea53722806401fdca36 /llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp | |
parent | 74127fe8d7e29b710fd91737dce92c93a059a768 (diff) | |
download | bcm5719-llvm-ed2213e6efc1cc71a323f49585e859d6e41853ed.tar.gz bcm5719-llvm-ed2213e6efc1cc71a323f49585e859d6e41853ed.zip |
AMDGPU/SI: Incomplete shader binaries need to finish execution at the end
Reviewers: tstellarAMD, arsenm
Subscribers: arsenm
Differential Revision: http://reviews.llvm.org/D18058
llvm-svn: 263441
Diffstat (limited to 'llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp')
-rw-r--r-- | llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp b/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp index edcfb0889bb..7dd0d7bc8f7 100644 --- a/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp +++ b/llvm/lib/Target/AMDGPU/SILowerControlFlow.cpp @@ -486,6 +486,7 @@ bool SILowerControlFlow::runOnMachineFunction(MachineFunction &MF) { for (MachineFunction::iterator BI = MF.begin(), BE = MF.end(); BI != BE; ++BI) { + MachineBasicBlock *EmptyMBBAtEnd = NULL; MachineBasicBlock &MBB = *BI; MachineBasicBlock::iterator I, Next; for (I = MBB.begin(); I != MBB.end(); I = Next) { @@ -562,6 +563,29 @@ bool SILowerControlFlow::runOnMachineFunction(MachineFunction &MF) { case AMDGPU::SI_INDIRECT_DST_V16: IndirectDst(MI); break; + + case AMDGPU::S_ENDPGM: { + if (MF.getInfo<SIMachineFunctionInfo>()->returnsVoid()) + break; + + // Graphics shaders returning non-void shouldn't contain S_ENDPGM, + // because external bytecode will be appended at the end. + if (BI != --MF.end() || I != MBB.getFirstTerminator()) { + // S_ENDPGM is not the last instruction. Add an empty block at + // the end and jump there. + if (!EmptyMBBAtEnd) { + EmptyMBBAtEnd = MF.CreateMachineBasicBlock(); + MF.insert(MF.end(), EmptyMBBAtEnd); + } + + MBB.addSuccessor(EmptyMBBAtEnd); + BuildMI(*BI, I, MI.getDebugLoc(), TII->get(AMDGPU::S_BRANCH)) + .addMBB(EmptyMBBAtEnd); + } + + I->eraseFromParent(); + break; + } } } } |