This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Add test for a problem with noclobber metadata
ClosedPublic

Authored by foad on Jan 28 2022, 5:08 AM.

Details

Summary

If AMDGPUAnnotateUniformValues finds a load from a uniform pointer with
no potentially clobbering stores between the kernel entry point and the
load instruction, it adds noclobber metadata to the *address*. This is
unsafe because it can get applied to other loads in the same which do
have aliasing stores.

Diff Detail

Event Timeline

foad created this revision.Jan 28 2022, 5:08 AM
foad requested review of this revision.Jan 28 2022, 5:08 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 28 2022, 5:08 AM
foad added a comment.Jan 28 2022, 5:10 AM

Found by inspection but I think this is a real bug isn't it? I guess the fix is to put the noclobber metadata on the load instruction, not on the pointer, but then how do you get at it during instruction selection?

rampitec accepted this revision.Jan 28 2022, 12:34 PM

Ugh... These are different arguments which may alias. I guess you could do the same with a single gep being reused for loads and stores...

This revision is now accepted and ready to land.Jan 28 2022, 12:34 PM
foad added a comment.Jan 31 2022, 3:05 AM

Ugh... These are different arguments which may alias. I guess you could do the same with a single gep being reused for loads and stores...

Right, but if a store is followed by a load from the exact same address, I thought some other pass might optimise the load away by replacing it with the value that was stored.

This revision was landed with ongoing or failed builds.Jan 31 2022, 3:09 AM
This revision was automatically updated to reflect the committed changes.

Ugh... These are different arguments which may alias. I guess you could do the same with a single gep being reused for loads and stores...

Right, but if a store is followed by a load from the exact same address, I thought some other pass might optimise the load away by replacing it with the value that was stored.

That's a slippery ground. It should be better to find a way to attach it right to a load.

We could implement TLI::getTargetMMOFlags() and set a target flag on the MMO.

foad added a comment.Feb 2 2022, 4:08 AM

We could implement TLI::getTargetMMOFlags() and set a target flag on the MMO.

Good idea! D118775.