[funcattrs] Infer writeonly argument attribute
authorPhilip Reames <listmail@philipreames.com>
Thu, 2 Dec 2021 20:56:09 +0000 (12:56 -0800)
committerPhilip Reames <listmail@philipreames.com>
Thu, 2 Dec 2021 21:04:09 +0000 (13:04 -0800)
commit740057d185ea0e8b5a4f8b7c78fdf38ae7a66f76
tree9f017ad3f877864ca8aa280f205892d236fd329a
parenta9036f2eb42d2311d84198868e9e8ff060c79a95
[funcattrs] Infer writeonly argument attribute

This change extends the current logic for inferring readonly and readnone argument attributes to also infer writeonly.

This change is deliberately minimal; there's a couple of areas for follow up.
* I left out all call handling and thus any benefit from the SCC walk. When examining the test changes, I realized the existing code is imprecise, and am going to fix that in it's own revision before adding in the writeonly handling. (Mostly because updating the tests is hard when I, the human, can't figure out whether the result is correct.)
* I left out handling for storing a value (as opposed to storing to a pointer). This should benefit readonly/readnone as well, and applies to a bunch of other instructions. Seemed worth having as a separate review.

Differential Revision: https://reviews.llvm.org/D114963
17 files changed:
clang/test/CodeGen/SystemZ/systemz-inline-asm.c
clang/test/CodeGen/aarch64-sve-acle-__ARM_FEATURE_SVE_VECTOR_OPERATORS.c
clang/test/CodeGen/arm-vfp16-arguments2.cpp
clang/test/CodeGen/mips-vector-return.c
clang/test/CodeGen/mips64-nontrivial-return.cpp
clang/test/CodeGen/ms-mixed-ptr-sizes.c
clang/test/CodeGenOpenCL/amdgpu-abi-struct-coerce.cl
clang/test/CodeGenOpenCL/amdgpu-call-kernel.cl
clang/test/CodeGenOpenCL/kernels-have-spir-cc-by-default.cl
llvm/lib/Transforms/IPO/FunctionAttrs.cpp
llvm/test/Analysis/TypeBasedAliasAnalysis/functionattrs.ll
llvm/test/Feature/OperandBundles/pr26510.ll
llvm/test/Transforms/Coroutines/coro-async.ll
llvm/test/Transforms/FunctionAttrs/2009-01-02-LocalStores.ll
llvm/test/Transforms/FunctionAttrs/nocapture.ll
llvm/test/Transforms/FunctionAttrs/readattrs.ll
llvm/test/Transforms/FunctionAttrs/writeonly.ll