[InstCombine] Don't simplify calls without uses
authorNikita Popov <nikita.ppv@gmail.com>
Sat, 7 Mar 2020 19:21:09 +0000 (20:21 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 9 Mar 2020 17:47:46 +0000 (18:47 +0100)
commitc3ca6876ed0cf833dfde681e18c37ed288bb554c
treef8ce13fffa692fd5329a3eb69c74fa59feb06d59
parent829d377a98fd3ee087935ea215677e49c8b51b27
[InstCombine] Don't simplify calls without uses

When simplifying a call without uses, replaceInstUsesWith() is
going to do nothing, but we'll skip all following folds. We can
only run into this problem with calls that both simplify and are
not trivially dead if unused, which currently seems to happen only
with calls to undef, as the test diff shows. When extending
SimplifyCall() to handle "returned" attributes, this becomes a much
bigger problem, so I'm fixing this first.

Differential Revision: https://reviews.llvm.org/D75814
llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
llvm/test/Transforms/InstCombine/pr44245.ll