[InstSimplify] Simplify calls with "returned" attribute
authorNikita Popov <nikita.ppv@gmail.com>
Sat, 7 Mar 2020 15:34:34 +0000 (16:34 +0100)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 9 Mar 2020 17:53:47 +0000 (18:53 +0100)
commit45555c381926050bc45a3372b1af0e15650371b6
treef6a5d34bfb1b8d5ac628a178ade15b39aa0c394b
parenta8f76e99ba5966adc82afd98cea5d6239c1501ac
[InstSimplify] Simplify calls with "returned" attribute

If a call argument has the "returned" attribute, we can simplify
the call to the value of that argument. The "-inst-simplify" pass
already handled this for the constant integer argument case via
known bits, which is invoked in SimplifyInstruction. However,
non-constant (or non-int) arguments are not handled at all right now.

This addresses one of the regressions from D75801.

Differential Revision: https://reviews.llvm.org/D75815
llvm/lib/Analysis/InstructionSimplify.cpp
llvm/test/Analysis/ValueTracking/known-nonnull-at.ll
llvm/test/Transforms/InstCombine/align-attr.ll
llvm/test/Transforms/InstCombine/expensive-combines.ll
llvm/test/Transforms/InstCombine/fortify-folding.ll
llvm/test/Transforms/InstCombine/strcpy_chk-1.ll
llvm/test/Transforms/InstCombine/strncpy_chk-1.ll
llvm/test/Transforms/InstCombine/unused-nonnull.ll
llvm/test/Transforms/InstSimplify/call.ll