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

Puyan Lotfi via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 29 17:11:21 PDT 2019


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

Changes based on Matt+Justin's 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,8 @@
+# RUN: llc -mtriple aarch64-- -run-pass mir-canonicalizer %s -o %t \
+# RUN:   -verify-machineinstrs
+
+--- |
+  define void @foo() {
+    ret void
+  }
+...
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.202080.patch
Type: text/x-patch
Size: 912 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190530/f1879148/attachment.bin>


More information about the llvm-commits mailing list