[PATCH] D49165: Add, and infer, a nofree function attribute
Eli Friedman via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 10 18:59:26 PDT 2018
efriedma added inline comments.
================
Comment at: docs/LangRef.rst:1439
+ indirectly, call a memory-deallocation function (free, for example). As a
+ result, uncaptured pointers that are known to be dereferenceable prior to a
+ call to a function with the ``nofree`` attribute are still known to be
----------------
The "uncaptured" bit makes this useless for D48239; we have to assume any argument that isn't noalias is captured.
================
Comment at: lib/Transforms/IPO/FunctionAttrs.cpp:1228
+ StringRef FnName = Callee->getName();
+ if (TLI.getLibFunc(FnName, TLIFn))
+ return false;
----------------
This seems delicate; there are some C library functions which aren't "free", but can still free memory (like mmap). Not sure we recognize any functions like that at the moment, but we could add them. I'd prefer to add explicit logic to inferLibFuncAttributes.
If you are going to call getLibFunc, use the overload that takes a CallSite.
Repository:
rL LLVM
https://reviews.llvm.org/D49165
More information about the llvm-commits
mailing list