This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPUHSAMetadataStreamer] Do not assume ABI alignment for pointers
ClosedPublic

Authored by nikic on Jan 26 2022, 1:57 AM.

Details

Summary

AMDGPUHSAMetadataStreamer currently assumes that pointer arguments without align attribute have ABI alignment of the pointee type. This is incompatible with opaque pointers, but also plain incorrect: Pointer arguments without explicit alignment have alignment 1. It is the responsibility of the frontent to add correct align annotations.

Diff Detail

Event Timeline

nikic created this revision.Jan 26 2022, 1:57 AM
nikic requested review of this revision.Jan 26 2022, 1:57 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 26 2022, 1:57 AM
arsenm accepted this revision.Jan 26 2022, 6:28 AM

LGTM, I swear I fixed this one before

This revision is now accepted and ready to land.Jan 26 2022, 6:28 AM
This revision was landed with ongoing or failed builds.Jan 26 2022, 6:45 AM
This revision was automatically updated to reflect the committed changes.

This change introduces the regression in OpenCL conformance test: basic - kernel_memory_alignment_local. Does it require any corresponding runtime changes?

arsenm added a comment.Feb 2 2022, 8:25 AM

This change introduces the regression in OpenCL conformance test: basic - kernel_memory_alignment_local. Does it require any corresponding runtime changes?

Is clang correctly emitting the align attribute on all these arguments?

This change introduces the regression in OpenCL conformance test: basic - kernel_memory_alignment_local. Does it require any corresponding runtime changes?

Is clang correctly emitting the align attribute on all these arguments?

clang does not do anything special for alignment of pointer type kernel arg. It assumes the pointee alignment is default 1. https://godbolt.org/z/xs195rKoW

Question is: What OpenCL spec says about kernel arg pointee alignment? @b-sumner @Anastasia

arsenm added a comment.Feb 2 2022, 8:57 AM

This change introduces the regression in OpenCL conformance test: basic - kernel_memory_alignment_local. Does it require any corresponding runtime changes?

Is clang correctly emitting the align attribute on all these arguments?

clang does not do anything special for alignment of pointer type kernel arg. It assumes the pointee alignment is default 1. https://godbolt.org/z/xs195rKoW

Question is: What OpenCL spec says about kernel arg pointee alignment? @b-sumner @Anastasia

It should be the ABI type alignment as was used before

This change introduces the regression in OpenCL conformance test: basic - kernel_memory_alignment_local. Does it require any corresponding runtime changes?

Is clang correctly emitting the align attribute on all these arguments?

clang does not do anything special for alignment of pointer type kernel arg. It assumes the pointee alignment is default 1. https://godbolt.org/z/xs195rKoW

Question is: What OpenCL spec says about kernel arg pointee alignment? @b-sumner @Anastasia

It should be the ABI type alignment as was used before

I doubt OpenCL spec requires alignment of pointer-type kernel argument. I suspect it is part of our own undocumented ABI. If we implement this in clang, it probably goes to TargetABIInfo.

I would suggest reverting this patch since it caused regressions. It should not be committed without corresponding clang change to maintain the ABI.

This change introduces the regression in OpenCL conformance test: basic - kernel_memory_alignment_local. Does it require any corresponding runtime changes?

Is clang correctly emitting the align attribute on all these arguments?

clang does not do anything special for alignment of pointer type kernel arg. It assumes the pointee alignment is default 1. https://godbolt.org/z/xs195rKoW

Question is: What OpenCL spec says about kernel arg pointee alignment? @b-sumner @Anastasia

It should be the ABI type alignment as was used before

I doubt OpenCL spec requires alignment of pointer-type kernel argument. I suspect it is part of our own undocumented ABI. If we implement this in clang, it probably goes to TargetABIInfo.

Yes it does, it requires natural alignment for all types which is what that conformance test is checking.

This change introduces the regression in OpenCL conformance test: basic - kernel_memory_alignment_local. Does it require any corresponding runtime changes?

Is clang correctly emitting the align attribute on all these arguments?

clang does not do anything special for alignment of pointer type kernel arg. It assumes the pointee alignment is default 1. https://godbolt.org/z/xs195rKoW

Question is: What OpenCL spec says about kernel arg pointee alignment? @b-sumner @Anastasia

It should be the ABI type alignment as was used before

I doubt OpenCL spec requires alignment of pointer-type kernel argument. I suspect it is part of our own undocumented ABI. If we implement this in clang, it probably goes to TargetABIInfo.

Yes it does, it requires natural alignment for all types which is what that conformance test is checking.

Agreed. OpenCL requires a alignof(T) to equal sizeof(T). There are vload/vstore functions to access vectors which are less aligned than their size.