[IR][LoopRotate] avoid leaving phi with no operands (PR48296)
authorSanjay Patel <spatel@rotateright.com>
Mon, 30 Nov 2020 13:59:40 +0000 (08:59 -0500)
committerSanjay Patel <spatel@rotateright.com>
Mon, 30 Nov 2020 14:28:45 +0000 (09:28 -0500)
commitbfd2c216ea8ef09f8fb1f755ca2b89f86f74acbb
treed938facf6d2676ba620c924aa5e2c2e121a18b6d
parent234a5297aa00648cba00347f24e9e9b99abde289
[IR][LoopRotate] avoid leaving phi with no operands (PR48296)

https://llvm.org/PR48296 shows an example where we delete all of the operands
of a phi without actually deleting the phi, and that is currently considered
invalid IR. The reduced test included here would crash for that reason.

A suggested follow-up is to loosen the assert to allow 0-operand phis
in unreachable blocks.

Differential Revision: https://reviews.llvm.org/D92247
llvm/include/llvm/IR/BasicBlock.h
llvm/lib/IR/BasicBlock.cpp
llvm/test/Transforms/LoopRotate/phi-empty.ll [new file with mode: 0644]