Skip to content

Add the 'initializes' attribute langref and support #84803

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 39 commits into from
Jun 21, 2024
Merged
Changes from 1 commit
Commits
Show all changes
39 commits
Select commit Hold shift + click to select a range
2554c82
Add 'initialized' attribute langref
haopliu Mar 11, 2024
a9256bf
Update the LangRef
haopliu Mar 12, 2024
9150ece
Refactor the argument uses collecting to a function
haopliu Mar 12, 2024
206b707
Add 'initialized' attribute support and undo the FunctionAttrs refact…
haopliu Mar 14, 2024
eaf5ca0
Update the LangRef (round 2)
haopliu Mar 14, 2024
52cc649
Update FoldingSet.h
haopliu Mar 14, 2024
f7fddb0
Change the attribute type to ConstantRangeList
haopliu Apr 5, 2024
3b5955a
Rename attr to initializes
haopliu Apr 5, 2024
6a1df7a
Update CRL about accessing the range of an EmptySet/FullSet
haopliu Apr 9, 2024
fe2e0a5
Change CRL.insert to be ordered and no overlapping
haopliu Apr 12, 2024
f73df04
Optimize CRL::insert for common cases
haopliu Apr 16, 2024
63c45f6
Update ConstantRangeList
haopliu Apr 16, 2024
dcc2b38
Add unit tests for BitcodeReader/Verifier/Assembler
haopliu Apr 17, 2024
9723322
Add a space after commas
haopliu Apr 17, 2024
e70988d
Update CRL and unit tests
haopliu Apr 18, 2024
9782c31
Update CRL to merge consecutive ranges
haopliu Apr 23, 2024
a924dd3
Handle a common case in CRL::insert and add CRL::dump
haopliu Apr 23, 2024
45cdc34
Nit: change dbgs() to llvm::dbgs()
haopliu Apr 24, 2024
4eeba08
Change the attr impl to TrailingObjects<ConstantRange>
haopliu Apr 25, 2024
502e062
Update LLVMContextImpl.h
haopliu Apr 26, 2024
fac03b8
Merge branch 'llvm:main' into dse-commit
haopliu May 8, 2024
ea3e7c5
Rebase to the latest main
haopliu May 8, 2024
7630510
Change getInitializes() to return ArrayRef<ConstantRange>
haopliu May 8, 2024
a604b4f
Remove llvm::
haopliu May 8, 2024
f941b24
Update LangRef and ConstantRangeList
haopliu May 9, 2024
e52fd9d
Update BitCodeReader/Writer
haopliu May 9, 2024
8e64fa9
Encode bitwidth once for ConstantRangeList kind attr
haopliu May 9, 2024
9ae0fca
Use SpecificBumpPtrAllocator to allocate mem and make sure to call de…
haopliu May 16, 2024
d4809ab
Refactor readConstantRange and update BitcodeReader
haopliu May 17, 2024
99d36cc
Merge branch 'main' into dse-commit
haopliu May 28, 2024
96191cd
Change the attr imple back to ConstantRangeList
haopliu May 30, 2024
645f577
Add getConstantRangeList unittest
haopliu May 30, 2024
2a8ea9a
Add Bitwidth in FoldingSetNodeId
haopliu Jun 11, 2024
37edecd
Merge branch 'main' into dse-commit
haopliu Jun 11, 2024
80306d7
Clean up a redundant check in BitcodeReader
haopliu Jun 11, 2024
67445fe
Change attr impl to normal Alloc w/ a vector and call dtor for each a…
haopliu Jun 18, 2024
68643a5
nit: use uninitialized_copy in the ConstantRangeListAttributeImpl ctor
haopliu Jun 18, 2024
46e8d87
Remove redundant BitWidth in the attr Profile as APInt::Profile alrea…
haopliu Jun 20, 2024
714d02f
Use ConstantRange::contains() in ConstantRangeList::insert()
haopliu Jun 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions llvm/docs/LangRef.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "with no overlapping or adjoining list elements"? or something like that (felt like it was missing a word at the end at least)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should start this off with a one sentence overview of the attribute. So starting with something like "This indicates that the function initializes the ranges of the pointer parameter's memory." Then describe what "initialize" means. Then the random details like non-overlapping/continuous ranges at the end.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "in case the argument points partway into an allocation." ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!


This attribute implies that the function initializes and does not read
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wouldn't use implies.

`This attribute only holds for the memory accessed via this pointer parameter. Other arbitrary accesses to the same memory via other pointers are allowed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

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``
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: "does not imply [the] initialized attribute, and ... writeonly, since initialized allows reading from the pointer after writing." ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd separate this into two sentences.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

as mentioned in the RFC, we should be more accurate here. the part of the attribute where the memory is read from before a write still must apply on the unwind edge. Also, I'd move this up since this is important to the semantics

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry, I meant that the memory is not read from before a write

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done!

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
Expand Down