From 8578c2b6fb2670275609e1c6c3cbbdf6a755fb83 Mon Sep 17 00:00:00 2001 From: Marek Olsak Date: Wed, 13 Jan 2016 17:23:12 +0000 Subject: [PATCH] AMDGPU/SI: Remove ending s_endpgm from non-void functions Reviewers: tstellarAMD, arsenm Subscribers: arsenm Differential Revision: http://reviews.llvm.org/D16035 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@257623 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Target/AMDGPU/SIInsertWaits.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Target/AMDGPU/SIInsertWaits.cpp b/lib/Target/AMDGPU/SIInsertWaits.cpp index d3b41797871..94e614750d2 100644 --- a/lib/Target/AMDGPU/SIInsertWaits.cpp +++ b/lib/Target/AMDGPU/SIInsertWaits.cpp @@ -494,6 +494,14 @@ bool SIInsertWaits::runOnMachineFunction(MachineFunction &MF) { // Wait for everything at the end of the MBB Changes |= insertWait(MBB, MBB.getFirstTerminator(), LastIssued); + + // Functions returning something shouldn't contain S_ENDPGM, because other + // bytecode will be appended after it. + if (!ReturnsVoid) { + MachineBasicBlock::iterator I = MBB.getFirstTerminator(); + if (I != MBB.end() && I->getOpcode() == AMDGPU::S_ENDPGM) + I->eraseFromParent(); + } } return Changes; -- 2.34.1