Deducing nofree atrribute for function arguments.
I'm glad you work on this, this will be helpful for h2s and also deref analysis. I added some comments.
remove it completely please
Look at the function attribute first, as long as it is set we do not have to prove anything but can just keep the optimistic state.
This above is not necessary if you use the function of the argument first to justify nofree.
unknown users need to be treated as potential frees.
I doubt calling indicateOptimisticFixpoint is correct.
I would put the logic that follows uses into the floating version and make everything that is not function scope (function & call site) derive from floating. (We need to have a generic use visitor but that is a different story)
We need tests where one argument is freed and one is not. Also where either one of two is freed but we don't know which (e.g., due to a phi). And we need uncertainty tests, e.g. the argument escapes and the function (wrt. to the argument) is not nofree.
Ok, I agree. This is how I should have done it.
I can do that. Just want to make sure I understand what you are saying. I should keep the current function & call site implementations, right?
I also thought about generic use visitor, I'll think about it and maybe write a patch this week.
I will add more tests soon. Actually a lot of tests will be affected, so maybe we are already covering some of the things you are mentioning.
Keep function & call site as is, yes.
If you want to work on a use visitor that is fine with me. Having edge-wise liveness information is also up there on the list of things I'd like to have.
OK, we could add them either way to make it explicit ;)
I think the logic is fine, some minor comments though. Also, could you update the use in AAHeapToStackImpl::updateImpl to ask for the call site argument instead (with test for the improvement if we don't have one yet)?
LangRef also needs to be updated I guess.
F = getIRPosition().getAnchorScope()
Why do we need an argument in the first place here (and why do you dereference it in 1419 before you check it for null in 1421, it can be null btw.).
(Arg->getParent()) -> F
use cast here. Users *have* to be instructions or we have way more problems (and we want it to explode if a user is not an instruction).
you need to treat uses in the operand bundle as "freeing", so, isCalleeOperand -> ok, isArgOperand -> test further, if neither -> not nofree.
no need for this check
overwrite manifest here to ensure we do not add "no-free" to the return value even if we derive it. We can actually derive it as we do not need to restrict it to arguments in the AANoFreeFloating::update.
Why do we need an argument and not just the associated value?
Allow PHI nodes and selects as well. Same as bitcast above.
This is still open, see my "why arguments" comment above.
Btw. later we can actually add "nofree" to return values (and call site returns) as it can help to keep dereferenceable. But that is for a follow up patch after we get dereferenceable_globally
ATTRIBUTOR: check line missing
Also replace the CHECK with ATTRIBUTOR
Small nits. Otherwise LGTM.
Also, make sure we have a test with 2 pointer arguments, one freed, one no-free annotated.
Replace IRPosition::function(*F)) with IRPosition::function_scope(IRP).
Hoist this out of the loop
I don't think this is necessary but fine with me. (should be implied and checked by the call site argument attr).