[nofree] Restrict semantics to memory visible to caller
authorPhilip Reames <listmail@philipreames.com>
Fri, 16 Apr 2021 18:37:36 +0000 (11:37 -0700)
committerPhilip Reames <listmail@philipreames.com>
Fri, 16 Apr 2021 18:38:55 +0000 (11:38 -0700)
commitff55d01a8e1b60c137cd8cab7d9eeef14284fd7a
tree905a719f5648bd40fd65be731a91fcd67e2bd1be
parent0daf27302518dcc521fae5cb5c7f72b783c13c35
[nofree] Restrict semantics to memory visible to caller

This patch clarifies the semantics of the nofree function attribute to make clear that it provides an "as if" semantic. That is, a nofree function is guaranteed not to free memory which existed before the call, but might allocate and then deallocate that same memory within the lifetime of the callee.

This is the result of the discussion on llvm-dev under the thread "Ambiguity in the nofree function attribute".

The most important part of this change is the LangRef wording. The rest is minor comment changes to emphasize the new semantics where code was accidentally consistent, and fix one place which wasn't consistent. That one place is currently narrowly used as it is primarily part of the ongoing (and not yet enabled) deref-at-point semantics work.

Differential Revision: https://reviews.llvm.org/D100141
llvm/docs/LangRef.rst
llvm/lib/IR/Value.cpp
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/LICM/hoist-alloc.ll
llvm/test/Transforms/LoopVectorize/X86/load-deref-pred.ll