llvm-reduce: Fix assertion on blockaddress during function reduction
authorMatt Arsenault <Matthew.Arsenault@amd.com>
Tue, 3 Jan 2023 17:45:42 +0000 (12:45 -0500)
committerMatt Arsenault <arsenm2@gmail.com>
Wed, 11 Jan 2023 13:10:04 +0000 (08:10 -0500)
commitae6a5c1d08d8ac251a2b3dc08b023126b21b1b53
tree8875785a6c4e5e5631aaa92d72c72e1c49250a47
parent2d6e280223cca4e44882245feb06e0c50d4c6375
llvm-reduce: Fix assertion on blockaddress during function reduction

Just avoid crashing for now, we should be able to replace the blockaddresses
themselves.

BlockAddress::handleOperandChangeImpl assumes it can cast to Function.
The verifier seems nonexistent and the langref isn't particularly explicit
on what's allowed as a blockaddress operand. As far as I can tell bugpoint
isn't doing anything to handle this.

Something low level is broken with BlockAddress handling,
demonstrated by reduce-functions-blockaddress-wrong-function.ll.
The BasicBlock destructor of the deleted function is triggering replacement
of blockaddresses for the kept function in some cases. I've only half debugged
this but it seems like blockaddress is handled too-specially compared to other
Constants. I have tentative patches to allow any constant to be a blockaddress
input, but having the verifier check if it's really a function/block.

https://reviews.llvm.org/D140909
llvm/test/tools/llvm-reduce/reduce-functions-blockaddress-wrong-function.ll [new file with mode: 0644]
llvm/test/tools/llvm-reduce/reduce-functions-blockaddress.ll [new file with mode: 0644]
llvm/tools/llvm-reduce/deltas/ReduceFunctions.cpp
llvm/tools/llvm-reduce/deltas/Utils.cpp
llvm/tools/llvm-reduce/deltas/Utils.h