[PATCH] D123088: attributes: introduce allockind attr for describing allocator fn behavior

Nikita Popov via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 2 12:31:23 PDT 2022


nikic added inline comments.


================
Comment at: llvm/docs/LangRef.rst:1581
+``allockind("KIND")``
+    Describes the behavior of an allocation function. The KIND string is comma
+    separated entries from the following options:
----------------
"string is" -> "string contains"?


================
Comment at: llvm/docs/LangRef.rst:1584
+     * "new": the function returns a new block of memory, or null if the
+       allocation fails
+     * "resize": the function returns a new block of memory or null. If the
----------------
Should reference `"alloc"` now. Also, I'd suggest to rename `resize` -> `realloc` to fully stick with the usual alloc/realloc/free terminology.


================
Comment at: llvm/docs/LangRef.rst:1601
+    describe more details of how the function behaves. The remaining options
+    are ignored for "free"-type functions.
 ``allocsize(<EltSizeParam>[, <NumEltsParam>])``
----------------
Would it be preferable to forbid them (in the IR verifier) instead?


================
Comment at: llvm/include/llvm/Support/CodeGen.h:19
+
+#include "llvm/ADT/BitmaskEnum.h"
+
----------------
Changes no longer needed.


================
Comment at: llvm/lib/IR/Attributes.cpp:461
+      parts.push_back("alloc");
+    }
+    if ((Kind & AllocFnKind::Resize) != AllocFnKind::Unknown) {
----------------
Can drop the braces from these, as they're single-line.


================
Comment at: llvm/test/Assembler/allockind-missing.ll:4
+declare void @f0() allockind()
+; CHECK: :[[#@LINE-1]]:30: error: expected allockind value
----------------
Oh, fancy. TIL about `#@LINE-1`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D123088/new/

https://reviews.llvm.org/D123088



More information about the llvm-commits mailing list