[PATCH] D81656: [AMDGPU][CODEGEN] Corrected lowering of inline asm in bundles

Dmitry Preobrazhensky via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 11 07:42:03 PDT 2020


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

See bug 46285 <https://bugs.llvm.org/show_bug.cgi?id=46285>

This is an incomplete change - it requires access to AsmPrinter::emitInlineAsm which is currently defined as private in AsmPrinter.h.
If you think this change is fine I'll create a separate fix to make this function accessible in subclasses.


https://reviews.llvm.org/D81656

Files:
  llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
  llvm/test/CodeGen/AMDGPU/inline-asm.ll


Index: llvm/test/CodeGen/AMDGPU/inline-asm.ll
===================================================================
--- llvm/test/CodeGen/AMDGPU/inline-asm.ll
+++ llvm/test/CodeGen/AMDGPU/inline-asm.ll
@@ -316,3 +316,13 @@
   tail call void asm sideeffect "; use $0", "v"(i64 %v1)
   ret void
 }
+
+; Check inline assembler in bundles.
+; CHECK-LABEL: bundle
+; CHECK: s_mov_b32 s0, 11
+; CHECK: s_mov_b64 s[0:1], 42
+define amdgpu_kernel void @bundle() {
+  call void asm sideeffect "s_mov_b32 s0, $0", "i"(i32 11)
+  call void asm sideeffect "s_mov_b64 s[0:1], $0", "i"(i64 42)
+  ret void
+}
Index: llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
===================================================================
--- llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
+++ llvm/lib/Target/AMDGPU/AMDGPUMCInstLower.cpp
@@ -272,7 +272,12 @@
     const MachineBasicBlock *MBB = MI->getParent();
     MachineBasicBlock::const_instr_iterator I = ++MI->getIterator();
     while (I != MBB->instr_end() && I->isInsideBundle()) {
-      emitInstruction(&*I);
+      if ((&*I)->getOpcode() == TargetOpcode::INLINEASM ||
+          (&*I)->getOpcode() == TargetOpcode::INLINEASM_BR) {
+        emitInlineAsm(&*I);
+      } else {
+        emitInstruction(&*I);
+      }
       ++I;
     }
   } else {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81656.270126.patch
Type: text/x-patch
Size: 1283 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200611/d9ef4f1e/attachment.bin>


More information about the llvm-commits mailing list