This is an archive of the discontinued LLVM Phabricator instance.

[SimplifyLibCalls] Add noalias from known callsites
ClosedPublic

Authored by xbolva00 on Aug 13 2019, 4:15 AM.

Diff Detail

Repository
rL LLVM

Event Timeline

xbolva00 created this revision.Aug 13 2019, 4:15 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 13 2019, 4:15 AM
xbolva00 updated this revision to Diff 214803.Aug 13 2019, 4:23 AM
uenoku added a subscriber: uenoku.Aug 13 2019, 4:50 AM

I can't be sure whether this marking is sound.

void g(char *p); // maybe capture p
void f(char *p, char *q){
    g(p);
    memcpy(p, q, 10);
}

In the case above, I think we cannot mark p as noalias in memcpy callsite. Do I misunderstand the semantic of memcpy?

“ // The semantics of memcpy intrinsics forbid overlap between their respective

// operands, i.e., source and destination of any given memcpy must no-alias.”

(Alias analysis’s code comment)

Yeah, the much harder thing is noalias propagation from callsite (Attributor)

“ // The semantics of memcpy intrinsics forbid overlap between their respective

// operands, i.e., source and destination of any given memcpy must no-alias.”

(Alias analysis’s code comment)

I understand. Thanks.

Yeah, the much harder thing is noalias propagation from callsite (Attributor)

Correct, see https://bugs.llvm.org/show_bug.cgi?id=39546

xbolva00 retitled this revision from [SimplifyLibCalls] Add noalias from known callsites [WIP] to [SimplifyLibCalls] Add noalias from known callsites .Aug 13 2019, 8:29 AM

Tests without a constant size are missing:
strcpy(a, b)

lib/Transforms/Utils/SimplifyLibCalls.cpp
527 ↗(On Diff #214803)

See the missing test comment.

991 ↗(On Diff #214803)

The size check is not necessary. If the size is 0 (statically or dynamicaly) there are no accesses, consequently "all" accesses adhere to the noalias definition.

xbolva00 updated this revision to Diff 214849.Aug 13 2019, 9:02 AM
xbolva00 retitled this revision from [SimplifyLibCalls] Add noalias from known callsites to [SimplifyLibCalls] Add noalias from known callsites.
xbolva00 edited the summary of this revision. (Show Details)

Addressed review notes.
Added tests.

This revision is now accepted and ready to land.Aug 13 2019, 10:07 AM
This revision was automatically updated to reflect the committed changes.
xbolva00 marked an inline comment as done.