-
Notifications
You must be signed in to change notification settings - Fork 15.1k
[IR] Introduce !captures metadata #160913
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1398,5 +1398,73 @@ define void @assume_nonnull(ptr %p) { | |
| ret void | ||
| } | ||
|
|
||
| define void @captures_metadata_address_is_null(ptr %x, ptr %y) { | ||
| ; FNATTRS: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) | ||
| ; FNATTRS-LABEL: define void @captures_metadata_address_is_null | ||
| ; FNATTRS-SAME: (ptr captures(address_is_null) [[X:%.*]], ptr writeonly captures(none) initializes((0, 8)) [[Y:%.*]]) #[[ATTR17]] { | ||
| ; FNATTRS-NEXT: store ptr [[X]], ptr [[Y]], align 8, !captures [[META0:![0-9]+]] | ||
| ; FNATTRS-NEXT: ret void | ||
| ; | ||
| ; ATTRIBUTOR: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) | ||
| ; ATTRIBUTOR-LABEL: define void @captures_metadata_address_is_null | ||
| ; ATTRIBUTOR-SAME: (ptr nofree writeonly [[X:%.*]], ptr nofree nonnull writeonly captures(none) [[Y:%.*]]) #[[ATTR13]] { | ||
| ; ATTRIBUTOR-NEXT: store ptr [[X]], ptr [[Y]], align 8, !captures [[META0:![0-9]+]] | ||
| ; ATTRIBUTOR-NEXT: ret void | ||
| ; | ||
| store ptr %x, ptr %y, !captures !{!"address_is_null"} | ||
| ret void | ||
| } | ||
|
|
||
| define void @captures_metadata_address(ptr %x, ptr %y) { | ||
| ; FNATTRS: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) | ||
| ; FNATTRS-LABEL: define void @captures_metadata_address | ||
| ; FNATTRS-SAME: (ptr captures(address) [[X:%.*]], ptr writeonly captures(none) initializes((0, 8)) [[Y:%.*]]) #[[ATTR17]] { | ||
| ; FNATTRS-NEXT: store ptr [[X]], ptr [[Y]], align 8, !captures [[META1:![0-9]+]] | ||
| ; FNATTRS-NEXT: ret void | ||
| ; | ||
| ; ATTRIBUTOR: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) | ||
| ; ATTRIBUTOR-LABEL: define void @captures_metadata_address | ||
| ; ATTRIBUTOR-SAME: (ptr nofree writeonly [[X:%.*]], ptr nofree nonnull writeonly captures(none) [[Y:%.*]]) #[[ATTR13]] { | ||
| ; ATTRIBUTOR-NEXT: store ptr [[X]], ptr [[Y]], align 8, !captures [[META1:![0-9]+]] | ||
| ; ATTRIBUTOR-NEXT: ret void | ||
| ; | ||
| store ptr %x, ptr %y, !captures !{!"address"} | ||
| ret void | ||
| } | ||
|
|
||
| define void @captures_metadata_address_read_provenance(ptr %x, ptr %y) { | ||
| ; FNATTRS: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) | ||
| ; FNATTRS-LABEL: define void @captures_metadata_address_read_provenance | ||
| ; FNATTRS-SAME: (ptr captures(address, read_provenance) [[X:%.*]], ptr writeonly captures(none) initializes((0, 8)) [[Y:%.*]]) #[[ATTR17]] { | ||
| ; FNATTRS-NEXT: store ptr [[X]], ptr [[Y]], align 8, !captures [[META2:![0-9]+]] | ||
| ; FNATTRS-NEXT: ret void | ||
| ; | ||
| ; ATTRIBUTOR: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) | ||
| ; ATTRIBUTOR-LABEL: define void @captures_metadata_address_read_provenance | ||
| ; ATTRIBUTOR-SAME: (ptr nofree writeonly [[X:%.*]], ptr nofree nonnull writeonly captures(none) [[Y:%.*]]) #[[ATTR13]] { | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hopefully Attributor can be extended to infer the whole CaptureInfo too soon. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is tracked at #135610 -- but I see you're already assigned on that one ^^ |
||
| ; ATTRIBUTOR-NEXT: store ptr [[X]], ptr [[Y]], align 8, !captures [[META2:![0-9]+]] | ||
| ; ATTRIBUTOR-NEXT: ret void | ||
| ; | ||
| store ptr %x, ptr %y, !captures !{!"address", !"read_provenance"} | ||
| ret void | ||
| } | ||
|
|
||
| define void @captures_metadata_provenance(ptr %x, ptr %y) { | ||
| ; FNATTRS: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) | ||
| ; FNATTRS-LABEL: define void @captures_metadata_provenance | ||
| ; FNATTRS-SAME: (ptr captures(provenance) [[X:%.*]], ptr writeonly captures(none) initializes((0, 8)) [[Y:%.*]]) #[[ATTR17]] { | ||
| ; FNATTRS-NEXT: store ptr [[X]], ptr [[Y]], align 8, !captures [[META3:![0-9]+]] | ||
| ; FNATTRS-NEXT: ret void | ||
| ; | ||
| ; ATTRIBUTOR: Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: write) | ||
| ; ATTRIBUTOR-LABEL: define void @captures_metadata_provenance | ||
| ; ATTRIBUTOR-SAME: (ptr nofree writeonly [[X:%.*]], ptr nofree nonnull writeonly captures(none) [[Y:%.*]]) #[[ATTR13]] { | ||
| ; ATTRIBUTOR-NEXT: store ptr [[X]], ptr [[Y]], align 8, !captures [[META3:![0-9]+]] | ||
| ; ATTRIBUTOR-NEXT: ret void | ||
| ; | ||
| store ptr %x, ptr %y, !captures !{!"provenance"} | ||
| ret void | ||
| } | ||
|
|
||
| declare ptr @llvm.launder.invariant.group.p0(ptr) | ||
| declare ptr @llvm.strip.invariant.group.p0(ptr) | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suppose this may be somewhat target-specific as well, though, longer term, could one envision the frontend emitting, e.g., !"address" when storing a pointer to a non-integral address space (and would that imply reading the visibile bits)? Not specific to the change, but didn't find any mention either in \pointercapture on provenance when it comes to non-integral pointers.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Depends a bit on what kind of non-integral pointer we'd talking about here, but if it's about GC pointers, then you'd probably want the opposite, that is
!captures !{!"provenance"}to indicate that accesses through the captured pointer are possible, but the address will not be inspected? Assuming the language does in fact not expose pointer addresses. I haven't thought too carefully on whether this would be safe. (Though I don't think we currently have any transforms that are able to take advantage of this.)