[PATCH] D62617: [MIR-Canon] Fixing case where MachineFunction is empty.

Puyan Lotfi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 30 14:14:51 PDT 2019


plotfi updated this revision to Diff 202300.
plotfi added a comment.

Addressing Justin's latest feedback.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D62617

Files:
  llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
  llvm/test/CodeGen/MIR/AArch64/empty-MF.mir


Index: llvm/test/CodeGen/MIR/AArch64/empty-MF.mir
===================================================================
--- /dev/null
+++ llvm/test/CodeGen/MIR/AArch64/empty-MF.mir
@@ -0,0 +1,11 @@
+# RUN: llc -mtriple aarch64-- -run-pass mir-canonicalizer %s -o - | FileCheck %s
+# CHECK: ...
+# CHECK-NEXT: ---
+# CHECK-NEXT: name:            foo
+# CHECK: body:             |
+# CHECK-EMPTY:
+# CHECK-NEXT: ...
+---
+name: foo
+body:             |
+...
Index: llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
===================================================================
--- llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
+++ llvm/lib/CodeGen/MIRCanonicalizerPass.cpp
@@ -104,6 +104,8 @@
                     "Rename Register Operands Canonically", false, false)
 
 static std::vector<MachineBasicBlock *> GetRPOList(MachineFunction &MF) {
+  if (MF.empty())
+    return {};
   ReversePostOrderTraversal<MachineBasicBlock *> RPOT(&*MF.begin());
   std::vector<MachineBasicBlock *> RPOList;
   for (auto MBB : RPOT) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D62617.202300.patch
Type: text/x-patch
Size: 1012 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190530/6bba19f6/attachment.bin>


More information about the llvm-commits mailing list