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

In cases where the machine function is empty: bail on the RPO traversal.

Differential Revision: https://reviews.llvm.org/D62617

llvm-svn: 362158
This commit is contained in:
Puyan Lotfi 2019-05-30 21:37:25 +00:00
parent fc3dfd3e35
commit daaecf98c9
2 changed files with 13 additions and 0 deletions

View File

@ -104,6 +104,8 @@ INITIALIZE_PASS_END(MIRCanonicalizer, "mir-canonicalizer",
"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) {

View File

@ -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: |
...