[llvm] Add 'initialized' attribute langref (PR #84803)
via llvm-commits
llvm-commits at lists.llvm.org
Mon Mar 11 14:24:21 PDT 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-llvm-ir
Author: Haopeng Liu (haopliu)
<details>
<summary>Changes</summary>
We propose adding a new LLVM attribute, `initialized((Lo1,Hi1),(Lo2,Hi2),...)`, which expresses the notion of memory space (i.e., intervals, in bytes) that the argument pointing to is initialized in the function.
Will commit the attribute inferring in the follow-up PRs.
https://discourse.llvm.org/t/rfc-llvm-new-initialized-parameter-attribute-for-improved-interprocedural-dse/77337
---
Full diff: https://github.com/llvm/llvm-project/pull/84803.diff
1 Files Affected:
- (modified) llvm/docs/LangRef.rst (+22)
``````````diff
diff --git a/llvm/docs/LangRef.rst b/llvm/docs/LangRef.rst
index b70220dec92615..39a555edfa80d6 100644
--- a/llvm/docs/LangRef.rst
+++ b/llvm/docs/LangRef.rst
@@ -1621,6 +1621,28 @@ Currently, only the following parameter attributes are defined:
``readonly`` or a ``memory`` attribute that does not contain
``argmem: write``.
+``initialized((Lo1,Hi1),...)``
+ This attribute is a list of const ranges in ascending order with no
+ overlapping or continuous. It indicates that the function initializes the
+ memory through the pointer argument, [%p+LoN, %p+HiN): there are no reads,
+ and no special accesses (such as volatile access or untrackable capture)
+ before the initialization in the function. LoN/HiN are 64-bit ints;
+ negative values are allowed in case a pointer to partway through the
+ allocation is passed to.
+
+ This attribute implies that the function initializes and does not read
+ before initialization through this pointer argument, even though it may
+ read the memory before initialization that the pointer points to, such
+ as through other arguments.
+
+ The ``writable`` or ``dereferenceable`` attribute does not imply
+ ``initialized`` attribute, and ``initialized`` does not imply ``writeonly``
+ since cases that read from the pointer after write, can be ``initialized``
+ but not ``writeonly``.
+
+ Note that this attribute does not apply to the unwind edge: the memory may
+ not actually be written to when unwinding happens.
+
``dead_on_unwind``
At a high level, this attribute indicates that the pointer argument is dead
if the call unwinds, in the sense that the caller will not depend on the
``````````
</details>
https://github.com/llvm/llvm-project/pull/84803
More information about the llvm-commits
mailing list