[PATCH] D149191: [CodeGen][MachineLastInstrsCleanup] fix INLINEASM_BR hazard

Nick Desaulniers via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 26 13:20:03 PDT 2023


nickdesaulniers updated this revision to Diff 517289.
nickdesaulniers retitled this revision from "[CodeGen][MachineLastInstrsCleanup] don't hoist loads above INLINEASM" to "[CodeGen][MachineLastInstrsCleanup] fix INLINEASM_BR hazard".
nickdesaulniers edited the summary of this revision.
nickdesaulniers added subscribers: ardb, nathanchance.
nickdesaulniers added a comment.

- new change


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D149191/new/

https://reviews.llvm.org/D149191

Files:
  llvm/lib/CodeGen/MachineLateInstrsCleanup.cpp
  llvm/test/CodeGen/AArch64/machine-latecleanup-inlineasm.mir


Index: llvm/test/CodeGen/AArch64/machine-latecleanup-inlineasm.mir
===================================================================
--- llvm/test/CodeGen/AArch64/machine-latecleanup-inlineasm.mir
+++ llvm/test/CodeGen/AArch64/machine-latecleanup-inlineasm.mir
@@ -160,8 +160,9 @@
   ; CHECK-NEXT: {{  $}}
   ; CHECK-NEXT: bb.1.bb8 (machine-block-address-taken, inlineasm-br-indirect-target):
   ; CHECK-NEXT:   successors: %bb.2(0x80000000)
-  ; CHECK-NEXT:   liveins: $w20, $x19, $x21, $x22, $x23, $x24, $x8
+  ; CHECK-NEXT:   liveins: $w20, $x19, $x21, $x22, $x23, $x24
   ; CHECK-NEXT: {{  $}}
+  ; CHECK-NEXT:   renamable $x8 = MOVi64imm 29273397577910035
   ; CHECK-NEXT:   renamable $x8 = ADDXri killed renamable $x8, 2048, 0
   ; CHECK-NEXT: {{  $}}
   ; CHECK-NEXT: bb.2.bb9:
Index: llvm/lib/CodeGen/MachineLateInstrsCleanup.cpp
===================================================================
--- llvm/lib/CodeGen/MachineLateInstrsCleanup.cpp
+++ llvm/lib/CodeGen/MachineLateInstrsCleanup.cpp
@@ -175,7 +175,8 @@
   Reg2DefMap &MBBDefs = RegDefs[MBB->getNumber()];
 
   // Find reusable definitions in the predecessor(s).
-  if (!MBB->pred_empty() && !MBB->isEHPad()) {
+  if (!MBB->pred_empty() && !MBB->isEHPad() &&
+      !MBB->isInlineAsmBrIndirectTarget()) {
     MachineBasicBlock *FirstPred = *MBB->pred_begin();
     for (auto [Reg, DefMI] : RegDefs[FirstPred->getNumber()])
       if (llvm::all_of(


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D149191.517289.patch
Type: text/x-patch
Size: 1423 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230426/83cdf8ce/attachment.bin>


More information about the llvm-commits mailing list