[PATCH] D76881: [AMDGPU] Skip CFIInstructions in SIInsertWaitcnts

Scott Linder via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 26 12:29:38 PDT 2020


scott.linder created this revision.
Herald added subscribers: llvm-commits, kerbowa, hiraditya, t-tye, tpr, dstuttard, yaxunl, nhaehnle, wdng, jvesely, kzhuravl, arsenm.
Herald added a project: LLVM.

CFI emitted during PEI at the beginning of the prologue needs to apply
to any inserted waitcnts on function entry.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D76881

Files:
  llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp


Index: llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
+++ llvm/lib/Target/AMDGPU/SIInsertWaitcnts.cpp
@@ -1640,13 +1640,17 @@
     // 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(),
+      BuildMI(EntryBB, I, 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);
 
     Modified = true;
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D76881.252944.patch
Type: text/x-patch
Size: 1066 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200326/6876356e/attachment-0001.bin>


More information about the llvm-commits mailing list