[PATCH] D62617: [MIR-Canon] Fixing case where MachineFunction is empty.
Justin Bogner via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Wed May 29 12:28:09 PDT 2019
bogner added inline comments.
================
Comment at: llvm/lib/CodeGen/MIRCanonicalizerPass.cpp:107
static std::vector<MachineBasicBlock *> GetRPOList(MachineFunction &MF) {
+ if (MF.begin() == MF.end())
+ return std::vector<MachineBasicBlock*>{};
----------------
`MF.empty()`?
================
Comment at: llvm/lib/CodeGen/MIRCanonicalizerPass.cpp:108
+ if (MF.begin() == MF.end())
+ return std::vector<MachineBasicBlock*>{};
ReversePostOrderTraversal<MachineBasicBlock *> RPOT(&*MF.begin());
----------------
Should be sufficient to write `return {};`
================
Comment at: llvm/test/CodeGen/MIR/AArch64/print-parse-overloaded-intrinsics.mir:5-6
+# RUN: llc -mtriple aarch64-- -run-pass mir-canonicalizer %s -o %t \
+# RUN: -verify-machineinstrs
+
----------------
plotfi wrote:
> arsenm wrote:
> > I don't see how the test is related?
> You have a good point. I will put together a separate test. This one just needs to be (empty MIR, but the IR part has a function):
>
> ```
> --- |
> define i32 @foo() {
> ret i32 0
> }
> ...
> ```
Agreed, it's probably better to create a simple test for this explicitly, and you should probably FileCheck that it passes the empty block through unchanged
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D62617/new/
https://reviews.llvm.org/D62617
More information about the llvm-commits
mailing list