This is an archive of the discontinued LLVM Phabricator instance.

[HIP] Fix pointer type kernel arg for amdgpu
AbandonedPublic

Authored by yaxunl on Nov 4 2019, 12:47 PM.

Details

Reviewers
tra
rjmccall
Summary

amdgpu target prefers pointer type kernel arg in default address space
to be coerced to device address space for better performance.

This patch fixes that.

Diff Detail

Event Timeline

yaxunl created this revision.Nov 4 2019, 12:47 PM
yaxunl updated this revision to Diff 227764.Nov 4 2019, 12:52 PM

add a test for non-kernel function.

tra added inline comments.Nov 4 2019, 1:51 PM
clang/lib/CodeGen/CGCall.cpp
1172

What's the purpose of this change?

clang/test/CodeGenCUDA/amdgpu-kernel-arg-pointer-type.cu
15–16

Interesting. Clang used to crash on explicit address space attribute in the past. I'm glad it works now.

yaxunl marked an inline comment as done.Nov 4 2019, 2:10 PM

BTW Michael Liao will create another patch which will supersede this patch. That patch contains similar changes and also handles pointers in a byval struct or array.

clang/lib/CodeGen/CGCall.cpp
1172

this is supposed to cast the coerced type to the original type. Previously, no coerced type changes the address space, therefore a bitcast is sufficient. Now we coerce a type to different address space, therefore we need a pointer cast.

yaxunl abandoned this revision.Nov 4 2019, 2:13 PM

Please review Michael's patch https://reviews.llvm.org/D69826 which supersedes this one. Thanks.