This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Add address space based alias analysis pass
ClosedPublic

Authored by rampitec on Mar 17 2017, 2:14 PM.

Details

Summary

This is direct port of HSAILAliasAnalysis pass, just cleaned for style and renamed.

Diff Detail

Repository
rL LLVM

Event Timeline

rampitec created this revision.Mar 17 2017, 2:14 PM
vpykhtin added inline comments.Mar 17 2017, 2:23 PM
lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
63 ↗(On Diff #92203)

the check can be done using xor

T1->isVectorTy() ^ T2->isVectorTy()

vpykhtin accepted this revision.Mar 17 2017, 2:23 PM

LGTM.

This revision is now accepted and ready to land.Mar 17 2017, 2:23 PM
arsenm added inline comments.Mar 17 2017, 2:26 PM
lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
1 ↗(On Diff #92203)

Missing comment

13 ↗(On Diff #92203)

doesn't match pass name

15–17 ↗(On Diff #92203)

Should move this to the TargetMachine when adding it

44 ↗(On Diff #92203)

flat and constant may alias, this isn't the OpenCL rules

58–59 ↗(On Diff #92203)

Use cast<> if not checking it

71 ↗(On Diff #92203)

formatting

78 ↗(On Diff #92203)

Missin space

lib/Target/AMDGPU/AMDGPUAliasAnalysis.h
1–2 ↗(On Diff #92203)

Missing comment

arsenm added inline comments.Mar 17 2017, 2:30 PM
lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
75–81 ↗(On Diff #92203)

We should probably be marking all constant loads in the frontend with invariant metadata.

83–101 ↗(On Diff #92203)

I think BasicAA will handle all of this, we should only need to handle the address spaces

test/CodeGen/AMDGPU/vectorize-global-local.ll
15–22 ↗(On Diff #92203)

Should run instnamer on this

rampitec marked 8 inline comments as done.Mar 17 2017, 2:39 PM
rampitec added inline comments.
lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
83–101 ↗(On Diff #92203)

It was not handled really, that's why it got here...

rampitec updated this revision to Diff 92207.Mar 17 2017, 2:41 PM

Addressed comments.

arsenm added inline comments.Mar 17 2017, 2:46 PM
lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
83–101 ↗(On Diff #92203)

I think this is only correct to do if F is a kernel

rampitec added inline comments.Mar 17 2017, 2:52 PM
lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
83–101 ↗(On Diff #92203)

You probably right, that is safer. I will change it. BTW, I have checked this method in BasicAA, it does not check argument attributes.

rampitec updated this revision to Diff 92210.Mar 17 2017, 2:56 PM
rampitec marked 2 inline comments as done.
rampitec added a reviewer: arsenm.

Added check if function is a kernel before assuming constant argument memory.

rampitec added inline comments.Mar 17 2017, 3:04 PM
lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
44 ↗(On Diff #92203)

I think in the future as an extension module metadata can be checked to see if source was OpenCL and return NoAlias for flat and constant.

arsenm accepted this revision.Mar 17 2017, 3:29 PM

LGTM

lib/Target/AMDGPU/AMDGPUAliasAnalysis.cpp
77 ↗(On Diff #92210)

This is redundant with the assert getPointerAddressSpace will do

44 ↗(On Diff #92203)

I think we really just need to mark constant accesses with invariant. Anything checking the raw language is broken

rampitec marked an inline comment as done.Mar 17 2017, 3:51 PM
This revision was automatically updated to reflect the committed changes.