[PATCH] D147060: [MachineSink] Fix an assertion failure in isCycleInvariant

antoine moynault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 29 00:01:00 PDT 2023


antmo updated this revision to Diff 509225.
antmo added a comment.

moved fix in FindCycleSinkCandidates


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D147060

Files:
  llvm/lib/CodeGen/MachineSink.cpp
  llvm/test/CodeGen/Generic/sink-insts-to-avoid-spills-debug-crash.ll


Index: llvm/test/CodeGen/Generic/sink-insts-to-avoid-spills-debug-crash.ll
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/Generic/sink-insts-to-avoid-spills-debug-crash.ll
@@ -0,0 +1,29 @@
+; RUN: llc -O2 -sink-insts-to-avoid-spills < %s | FileCheck %s
+; REQUIRES: aarch64-registered-target
+
+target triple = "aarch64-unknown-linux-gnu"
+
+; CHECK-LABEL: a:
+define i32 @a() {
+entry:
+  %call = tail call i32 @c()
+  call void @llvm.dbg.value(metadata i32 %call, metadata !3, metadata !DIExpression()), !dbg !8
+  br label %for.cond
+
+for.cond:                                         ; preds = %for.cond, %entry
+  br label %for.cond
+}
+
+declare i32 @c()
+declare void @llvm.dbg.value(metadata, metadata, metadata)
+
+!llvm.dbg.cu = !{!0}
+!llvm.module.flags = !{!2}
+
+!0 = distinct !DICompileUnit(language: DW_LANG_C11, file: !1)
+!1 = !DIFile(filename: "bcm.c", directory: "/")
+!2 = !{i32 2, !"Debug Info Version", i32 3}
+!3 = !DILocalVariable(name: "b", scope: !4, file: !1, line: 8, type: !7)
+!4 = distinct !DISubprogram(name: "a", scope: !1, unit: !0)
+!7 = !DIBasicType(name: "int", size: 32, encoding: DW_ATE_signed)
+!8 = !DILocation(line: 0, scope: !4)
Index: llvm/lib/CodeGen/MachineSink.cpp
===================================================================
--- llvm/lib/CodeGen/MachineSink.cpp
+++ llvm/lib/CodeGen/MachineSink.cpp
@@ -390,15 +390,15 @@
                            "target\n");
       continue;
     }
-    if (!isCycleInvariant(Cycle, MI)) {
-      LLVM_DEBUG(dbgs() << "CycleSink: Instruction is not cycle invariant\n");
-      continue;
-    }
     bool DontMoveAcrossStore = true;
     if (!MI.isSafeToMove(AA, DontMoveAcrossStore)) {
       LLVM_DEBUG(dbgs() << "CycleSink: Instruction not safe to move.\n");
       continue;
     }
+    if (!isCycleInvariant(Cycle, MI)) {
+      LLVM_DEBUG(dbgs() << "CycleSink: Instruction is not cycle invariant\n");
+      continue;
+    }
     if (MI.mayLoad() && !mayLoadFromGOTOrConstantPool(MI)) {
       LLVM_DEBUG(dbgs() << "CycleSink: Dont sink GOT or constant pool loads\n");
       continue;


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D147060.509225.patch
Type: text/x-patch
Size: 2141 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230329/418415c0/attachment.bin>


More information about the llvm-commits mailing list