Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 4 additions & 5 deletions llvm/lib/Transforms/IPO/FunctionAttrs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -908,7 +908,7 @@ determinePointerAccessAttrs(Argument *A,
for (Use &UU : CB.uses())
if (Visited.insert(&UU).second)
Worklist.push_back(&UU);
} else if (!CB.doesNotCapture(UseIndex)) {
} else if (capturesAnyProvenance(CB.getCaptureInfo(UseIndex))) {
if (!CB.onlyReadsMemory())
// If the callee can save a copy into other memory, then simply
// scanning uses of the call is insufficient. We have no way
Expand Down Expand Up @@ -1382,10 +1382,9 @@ static void addArgumentAttrs(const SCCNodeSet &SCCNodes,
}
}

// TODO(captures): Ignore address-only captures.
if (capturesAnything(CC)) {
// As the pointer may be captured, determine the pointer attributes
// looking at each argument individually.
if (capturesAnyProvenance(CC)) {
// As the pointer provenance may be captured, determine the pointer
// attributes looking at each argument individually.
for (ArgumentGraphNode *N : ArgumentSCC) {
if (DetermineAccessAttrsForSingleton(N->Definition))
Changed.insert(N->Definition->getParent());
Expand Down
4 changes: 2 additions & 2 deletions llvm/test/Transforms/FunctionAttrs/nocapture.ll
Original file line number Diff line number Diff line change
Expand Up @@ -1234,7 +1234,7 @@ define void @dont_increase_existing_captures_scc2(ptr %p) {
define void @addr_only_scc(ptr %p) {
; FNATTRS: Function Attrs: nofree nosync nounwind memory(write, argmem: read, inaccessiblemem: none)
; FNATTRS-LABEL: define void @addr_only_scc
; FNATTRS-SAME: (ptr captures(address_is_null) [[P:%.*]]) #[[ATTR20:[0-9]+]] {
; FNATTRS-SAME: (ptr readonly captures(address_is_null) [[P:%.*]]) #[[ATTR20:[0-9]+]] {
; FNATTRS-NEXT: [[V:%.*]] = load i8, ptr [[P]], align 1
; FNATTRS-NEXT: store i8 [[V]], ptr @g, align 1
; FNATTRS-NEXT: call void @addr_only_scc2(ptr [[P]])
Expand All @@ -1257,7 +1257,7 @@ define void @addr_only_scc(ptr %p) {
define void @addr_only_scc2(ptr %p) {
; FNATTRS: Function Attrs: nofree nosync nounwind memory(write, argmem: read, inaccessiblemem: none)
; FNATTRS-LABEL: define void @addr_only_scc2
; FNATTRS-SAME: (ptr captures(address_is_null) [[P:%.*]]) #[[ATTR20]] {
; FNATTRS-SAME: (ptr readonly captures(address_is_null) [[P:%.*]]) #[[ATTR20]] {
; FNATTRS-NEXT: [[CMP:%.*]] = icmp ne ptr [[P]], null
; FNATTRS-NEXT: br i1 [[CMP]], label [[IF:%.*]], label [[EXIT:%.*]]
; FNATTRS: if:
Expand Down