[PATCH] D73338: [AMDGPU] Fix GCN regpressure trackers for INLINEASM instructions

Valery Pykhtin via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 24 02:42:39 PST 2020


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

Replace iteration over defs() with operands() as INLINEASM instruction isn't compatible with defs() - it has completly different order of operands: asm string, flags and pairs of flags:operand. defs() assumes all def operands go sequentally from the beginning of operands.

How LLVM could work all these years? Should an assert not using on INLINEASM in defs be added?

Not sure how to test this.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D73338

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


Index: llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
+++ llvm/lib/Target/AMDGPU/GCNRegPressure.cpp
@@ -327,8 +327,9 @@
   // update max pressure
   MaxPressure = max(AtMIPressure, MaxPressure);
 
-  for (const auto &MO : MI.defs()) {
-    if (!MO.isReg() || !Register::isVirtualRegister(MO.getReg()) || MO.isDead())
+  for (const auto &MO : MI.operands()) {
+    if (!MO.isReg() || !MO.isDef() ||
+        !Register::isVirtualRegister(MO.getReg()) || MO.isDead())
       continue;
 
     auto Reg = MO.getReg();
@@ -403,8 +404,8 @@
   LastTrackedMI = &*NextMI++;
 
   // Add new registers or mask bits.
-  for (const auto &MO : LastTrackedMI->defs()) {
-    if (!MO.isReg())
+  for (const auto &MO : LastTrackedMI->operands()) {
+    if (!MO.isReg() || !MO.isDef())
       continue;
     Register Reg = MO.getReg();
     if (!Register::isVirtualRegister(Reg))


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73338.240135.patch
Type: text/x-patch
Size: 970 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200124/37032380/attachment.bin>


More information about the llvm-commits mailing list