[funcattrs] Fix a bug in recently introduced writeonly argument inference
authorPhilip Reames <listmail@philipreames.com>
Fri, 3 Dec 2021 16:52:40 +0000 (08:52 -0800)
committerPhilip Reames <listmail@philipreames.com>
Fri, 3 Dec 2021 16:57:15 +0000 (08:57 -0800)
commit7b54de5feffedfc08e5a02d6c9e27c54e3b7f119
tree7c530f9ec403777abe3d57118973d8772952a109
parent74cc0fa1db74d678436020a64a8ca0e9e99954d1
[funcattrs] Fix a bug in recently introduced writeonly argument inference

This fixes a bug in 740057d.  There's two ways to describe the issue:
* One caller hasn't yet proven nocapture on the argument.  Given that, the inference routine is responsible for bailing out on a potential capture.
* Even if we know the argument is nocapture, the access inference needs to traverse the exact set of users the capture tracking would (or exit conservatively).  Even if capture tracking can prove a store is non-capturing (e.g. to a local alloc which doesn't escape), we still need to track the copy of the pointer to see if it's later reloaded and accessed again.

Note that all the test changes except the newly added ones appear to be false negatives.  That is, cases where we could prove writeonly, but the current code isn't strong enough.  That's why I didn't spot this originally.
clang/test/CodeGen/ms-mixed-ptr-sizes.c
llvm/lib/Transforms/IPO/FunctionAttrs.cpp
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