[PATCH] D76881: [AMDGPU] Skip CFIInstructions in SIInsertWaitcnts
Scott Linder via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Thu Mar 26 13:36:09 PDT 2020
scott.linder updated this revision to Diff 252965.
scott.linder added a comment.
Add a test
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D76881/new/
https://reviews.llvm.org/D76881
Files:
llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
llvm/test/CodeGen/AMDGPU/waitcnt-skip-cfi.mir
Index: llvm/test/CodeGen/AMDGPU/waitcnt-skip-cfi.mir
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/AMDGPU/waitcnt-skip-cfi.mir
@@ -0,0 +1,23 @@
+# RUN: llc -march=amdgcn -mcpu=gfx900 -run-pass si-insert-waitcnts %s -o - | FileCheck %s
+
+--- |
+
+ define void @skip_cfi() {
+ ret void
+ }
+
+...
+---
+
+# Ensure we insert waitcnts after any CFI at the start of non-kernel functions
+
+# CHECK-LABEL: name: skip_cfi{{$}}
+# CHECK: frame-setup CFI_INSTRUCTION
+# CHECK: S_WAITCNT
+
+name: skip_cfi
+machineFunctionInfo:
+body: |
+ bb.0:
+ frame-setup CFI_INSTRUCTION undefined $sgpr0
+...
Index: llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -1640,13 +1640,15 @@
// TODO: Could insert earlier and schedule more liberally with operations
// that only use caller preserved registers.
MachineBasicBlock &EntryBB = MF.front();
+ MachineBasicBlock::iterator I = EntryBB.begin();
+ for (MachineBasicBlock::iterator E = EntryBB.end();
+ I != E && (I->isPHI() || I->isCFIInstruction()); ++I)
+ ;
+ BuildMI(EntryBB, I, DebugLoc(), TII->get(AMDGPU::S_WAITCNT)).addImm(0);
if (ST->hasVscnt())
- BuildMI(EntryBB, EntryBB.getFirstNonPHI(), DebugLoc(),
- TII->get(AMDGPU::S_WAITCNT_VSCNT))
- .addReg(AMDGPU::SGPR_NULL, RegState::Undef)
- .addImm(0);
- BuildMI(EntryBB, EntryBB.getFirstNonPHI(), DebugLoc(), TII->get(AMDGPU::S_WAITCNT))
- .addImm(0);
+ BuildMI(EntryBB, I, DebugLoc(), TII->get(AMDGPU::S_WAITCNT_VSCNT))
+ .addReg(AMDGPU::SGPR_NULL, RegState::Undef)
+ .addImm(0);
Modified = true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76881.252965.patch
Type: text/x-patch
Size: 1827 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200326/501aedca/attachment-0001.bin>
More information about the llvm-commits
mailing list