[IR] Clean up dead instructions after simplifying a conditional branch
authorJay Foad <jay.foad@amd.com>
Mon, 18 May 2020 18:12:29 +0000 (19:12 +0100)
committerJay Foad <jay.foad@amd.com>
Thu, 11 Jun 2020 13:53:01 +0000 (14:53 +0100)
commit69bdfb075b293c4b3363f2dc0ac732ca03c3c9ca
tree2ed2e13de96b881abf45f9aef601f831925e92c5
parent3d5f7c853173938c6bb8052220487fd9d2987a77
[IR] Clean up dead instructions after simplifying a conditional branch

Change BasicBlock::removePredecessor to optionally return a vector of
instructions which might be dead. Use this in ConstantFoldTerminator to
delete them if they are dead.

Reapply with a bug fix: don't drop the "!KeepOneInputPHIs" argument when
removePredecessor calls PHINode::removeIncomingValue.

Differential Revision: https://reviews.llvm.org/D80206
llvm/include/llvm/IR/BasicBlock.h
llvm/lib/IR/BasicBlock.cpp
llvm/lib/Transforms/Utils/Local.cpp
llvm/test/Transforms/PGOProfile/chr.ll