[PATCH] D49165: Add, and infer, a nofree function attribute

Hal Finkel via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jul 10 18:29:28 PDT 2018


hfinkel created this revision.
hfinkel added reviewers: efriedma, chandlerc.
Herald added subscribers: dexonsmith, steven_wu, bollu, eraman, nhaehnle, mcrosier, mehdi_amini.

This patch adds a function attribute, nofree, to indicate that a function does not, directly or indirectly, call a memory-deallocation function (e.g., free, C++'s operator delete).

The primary motivation for adding this attribute some from the discussion about how to fix the semantics, or the use of, the dereferenceable attribute on C++ references passed as function parameters. The problem is that, while a reference argument is known to be dereferenceable when the function starts executing, nothing prevents the function from freeing the memory. As a result, it is wrong to assume that the pointer is dereferenceable over the entire body of the function unless we can rule out a situation where the memory might be deallocated during the course of the function's execution. For more information, please see the discussion in https://reviews.llvm.org/D48239.

For more information, see the RFC.


Repository:
  rL LLVM

https://reviews.llvm.org/D49165

Files:
  docs/LangRef.rst
  include/llvm/Analysis/MemoryBuiltins.h
  include/llvm/Bitcode/LLVMBitCodes.h
  include/llvm/IR/Attributes.td
  include/llvm/IR/Function.h
  lib/Analysis/MemoryBuiltins.cpp
  lib/AsmParser/LLLexer.cpp
  lib/AsmParser/LLParser.cpp
  lib/AsmParser/LLToken.h
  lib/Bitcode/Reader/BitcodeReader.cpp
  lib/Bitcode/Writer/BitcodeWriter.cpp
  lib/IR/Attributes.cpp
  lib/IR/Verifier.cpp
  lib/Transforms/IPO/FunctionAttrs.cpp
  lib/Transforms/Utils/CodeExtractor.cpp
  test/Analysis/TypeBasedAliasAnalysis/functionattrs.ll
  test/Bitcode/attributes.ll
  test/CodeGen/AMDGPU/inline-attr.ll
  test/Feature/OperandBundles/function-attrs.ll
  test/Transforms/FunctionAttrs/atomic.ll
  test/Transforms/FunctionAttrs/nofree.ll
  test/Transforms/FunctionAttrs/operand-bundles-scc.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D49165.154913.patch
Type: text/x-patch
Size: 23391 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180711/078c24e5/attachment.bin>


More information about the llvm-commits mailing list