Update the check for the default exit block to not only check that the
terminator is not unreachable, but also check that unreachable block has
*only* the unreachable instruction.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp | ||
---|---|---|
601 | Rather than trying to name after the implementation, how about naming after the usage? IsTriviallyUnswitchableExitBlock? I'd also use a reference here, but that's a pretty minor point. | |
602–609 | I'd rewrite this to use early exit rather than combining flags, and add some comments about the non-obvious part (IMO, the non-empty unreachable). Something like: if (L.contains(BBToCheck)) return false; if (!areLoopExitPHIsLoopInvariant(L, *ParentBB, *BBToCheck)) return false; .... |
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp | ||
---|---|---|
614 | Need to skip debug info |
LGTM with the addition of skipping debug info as Eli suggests.
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp | ||
---|---|---|
614 | I hadn't expected that to matter as the thing we care most about here are the empty-but-unreachable blocks *created* by this same pass (and those would never have debug info). But I suppose you're right that we still need to skip debug info because then the frontend adding it could suddenly enable (pointless) unswitching. Ugh, but good catch. |
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp | ||
---|---|---|
614 | Just to clarify, when TI is an unreachable, the check should instead traverse BBToCheck and verify that if any instructions beside TI exists, they are an IntrinsicInstr and I->getIntrinsicID() is one of: Intrinsic::dbg_addr, Intrinsic::dbg_declare, Intrinsic::dbg_label or Intrinsic::dbg_value. Thanks for the input! |
llvm/lib/Transforms/Scalar/SimpleLoopUnswitch.cpp | ||
---|---|---|
614 | BBToCheck()->getFirstNonPHIOrDbg() != TI? |
Rather than trying to name after the implementation, how about naming after the usage? IsTriviallyUnswitchableExitBlock?
I'd also use a reference here, but that's a pretty minor point.