This is an archive of the discontinued LLVM Phabricator instance.

[Attributor] Deduce "noalias" attribute
ClosedPublic

Authored by uenoku on Aug 14 2019, 2:31 AM.

Details

Summary

Toward noalias backward propagation(similar to D65402), this patch adds AANoAliasArgument and AANoAliasCallSiteArgument as staring point.

Diff Detail

Repository
rL LLVM

Event Timeline

uenoku created this revision.Aug 14 2019, 2:31 AM
Herald added a project: Restricted Project. · View Herald TranscriptAug 14 2019, 2:31 AM
uenoku updated this revision to Diff 215059.Aug 14 2019, 2:35 AM

Fix test filename.

Minor comments

llvm/lib/Transforms/IPO/Attributor.cpp
1358 ↗(On Diff #215059)

this can now be auto CallSiteCheck = [&](CallSiteCheck CS){ ... }
In D66155 I changed checkForAllCallSites to also use llvm::function_ref

1375 ↗(On Diff #215059)

It looks like this is not the latest version of checkForAllCallSites. Now it also takes a function as a parameter.

uenoku marked an inline comment as done.Aug 14 2019, 4:58 AM
uenoku added inline comments.
llvm/lib/Transforms/IPO/Attributor.cpp
1375 ↗(On Diff #215059)

I created this patch based on D65977. In that patch, the interface will be changed. I forgot to say it, sorry.

jdoerfert added a comment.EditedAug 14 2019, 8:39 AM

Please add an SCC test and maybe also tests we cannot handle yet (see my link) and https://reviews.llvm.org/D50125#change-PYgdy9Zf8j2e

Edit: we don't need the extended functionality in this patch but tests would be nice.

llvm/lib/Transforms/IPO/Attributor.cpp
1398 ↗(On Diff #215059)

This is a good first step.

For an extension we could do something like this:
https://reviews.llvm.org/D50125#C1138972NL755

Can we make prioritize this, at least a simple version which is almost done, just the additional argument checks are missing (see below).

llvm/lib/Transforms/IPO/Attributor.cpp
1398 ↗(On Diff #215059)

See my example below, we need to check the other uses in the call site as I did in the link above.

llvm/test/Transforms/FunctionAttrs/noalias.ll
164 ↗(On Diff #215059)
; TEST 11
; CallSite Test

declare void @test11_helper(i8* %a, i8 *%b)
define void @test11(i8* noalias %a) {
; CHECK: define void @test11(i8* noalias %a)
; CHECK-NEXT:   tail call void @test11_helper(i8* %a, i8* %a)
  tail call void @test11_helper(i8* %a)
  ret void
}
uenoku updated this revision to Diff 217603.Aug 28 2019, 4:24 AM
uenoku retitled this revision from [Attributor] Add CallSiteArgument and Argument AbstractAttribute for noalias to [Attributor] Deduce "noalias" attribute.

Rebase and add test.

uenoku added inline comments.Aug 28 2019, 4:28 AM
llvm/lib/Transforms/IPO/Attributor.cpp
396 ↗(On Diff #217603)

About initialize, I think it suffices to ignore this line for call site argument.

jdoerfert added inline comments.Aug 28 2019, 6:55 AM
llvm/lib/Transforms/IPO/Attributor.cpp
1533 ↗(On Diff #217603)

I do not understand. Could you elaborate or point me to a test case?

uenoku marked an inline comment as done.Aug 28 2019, 7:48 AM
uenoku added inline comments.
llvm/lib/Transforms/IPO/Attributor.cpp
1533 ↗(On Diff #217603)
declare void @test11_helper(i8* %a)
define void @test11(i8* noalias %a) {
  tail call void @test11_helper(i8* %a) ; maybe captured
  %c = load i8 , i8* %a ; It is invalid to deduce noalias for %a because of noalias in argument
  ret void
}

Isn't it?

I think except the small nits below this is fine. We can get this in and work from there

llvm/lib/Transforms/IPO/Attributor.cpp
1533 ↗(On Diff #217603)

Ah, now I see your point. thx

llvm/test/Transforms/FunctionAttrs/internal-noalias.ll
8 ↗(On Diff #217603)

Add check lines above or use llvm/utils/update_test_checks.py for the test files.

llvm/test/Transforms/FunctionAttrs/noalias_returned.ll
145 ↗(On Diff #217603)

Missing noalias where? Maybe show how it should look like.

jdoerfert accepted this revision.Aug 28 2019, 9:33 AM

LGTM with small nits

This revision is now accepted and ready to land.Aug 28 2019, 9:33 AM
uenoku set the repository for this revision to rG LLVM Github Monorepo.Aug 28 2019, 10:27 AM
uenoku updated this revision to Diff 217768.Aug 28 2019, 9:35 PM

Address comment

uenoku updated this revision to Diff 217769.Aug 28 2019, 9:47 PM

Minor update

This revision was automatically updated to reflect the committed changes.