[InstCombine] Erase attribute lists for simplified libcalls
authorGui Andrade <guiand@google.com>
Tue, 7 Jul 2020 21:21:13 +0000 (21:21 +0000)
committerGui Andrade <guiand@google.com>
Mon, 13 Jul 2020 22:32:33 +0000 (22:32 +0000)
commitbfa3b627c6832552a7808a9f0f7f9cab61c7ea1a
tree23115555471949aead88f656ee03a499bcd98ab2
parent3d52b1e81b7b3891d9132d826d4889119fad7d00
[InstCombine] Erase attribute lists for simplified libcalls

Currently, a transformation like pow(2.0, x) -> exp2(x) copies the pow
attribute list verbatim and applies it to exp2. This works out fine
when the attribute list is empty, but when it isn't clang may error due
due to the mismatch.

The source function and destination don't necessarily have anything
to do with one another, attribute-wise. So it makes sense to remove
the attribute lists (this is similar to what IPO does in this
situation).

This was discovered after implementing the `noundef` param attribute.

Differential Revision: https://reviews.llvm.org/D82820
llvm/lib/Transforms/Utils/SimplifyLibCalls.cpp
llvm/test/Transforms/InstCombine/pow_fp_int.ll
llvm/test/Transforms/InstCombine/simplify-libcalls.ll