This is an archive of the discontinued LLVM Phabricator instance.

[AMDGPU] Kernel arg metadata: added support for "__hip_texture" type.
ClosedPublic

Authored by kpyzhov on Jun 26 2019, 4:22 PM.

Details

Summary

Added support for HIP texture kernel arguments to the MetadataStreamer.
For pointers to "__hip_texture", return ValueKind::Image.

Diff Detail

Repository
rL LLVM

Event Timeline

kpyzhov created this revision.Jun 26 2019, 4:22 PM
Herald added a project: Restricted Project. · View Herald Transcript

Does this need to be done for v3 as well? Needs test?

kpyzhov updated this revision to Diff 207796.Jul 3 2019, 7:47 AM
kpyzhov edited the summary of this revision. (Show Details)

Test for v3?

kpyzhov updated this revision to Diff 207799.Jul 3 2019, 8:06 AM
kzhuravl accepted this revision.Jul 3 2019, 8:12 AM

LGTM, thanks!

This revision is now accepted and ready to land.Jul 3 2019, 8:12 AM
yaxunl accepted this revision.Jul 3 2019, 8:16 AM

LGTM

This revision was automatically updated to reflect the committed changes.

Both tests fail with compiler crashing. Must always check hasName() before using getName().
I believe this needs to be reverted, this change will not work anyway if name was stripped, which llvm does.

llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -mattr=-code-object-v3 -amdgpu-dump-hsa-metadata -amdgpu-verify-hsa-metadata -filetype=obj -o - < test/CodeGen/AMDGPU/hsa-metadata-from-llvm-ir-full.ll
llc: /home/stas/work/llvm/llvm/lib/IR/Type.cpp:500: llvm::StringRef llvm::StructType::getName() const: Assertion `!isLiteral() && "Literal structs never have names"' failed.
Stack dump:
0.	Program arguments: /home/stas/work/llvm/bin/bin/llc -mtriple=amdgcn-amd-amdhsa -mcpu=gfx900 -mattr=-code-object-v3 -amdgpu-dump-hsa-metadata -amdgpu-verify-hsa-metadata -filetype=obj -o - 
1.	Running pass 'CallGraph Pass Manager' on module '<stdin>'.
2.	Running pass 'AMDGPU Assembly Printer' on function '@test_pointee_align'
 #0 0x0000000005ae8819 llvm::sys::PrintStackTrace(llvm::raw_ostream&) /home/stas/work/llvm/llvm/lib/Support/Unix/Signals.inc:494:11
 #1 0x0000000005ae89c9 PrintStackTraceSignalHandler(void*) /home/stas/work/llvm/llvm/lib/Support/Unix/Signals.inc:555:1
 #2 0x0000000005ae72d6 llvm::sys::RunSignalHandlers() /home/stas/work/llvm/llvm/lib/Support/Signals.cpp:67:5
 #3 0x0000000005ae906b SignalHandler(int) /home/stas/work/llvm/llvm/lib/Support/Unix/Signals.inc:357:1
 #4 0x00007f16e04bdf40 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x13f40)
 #5 0x00007f16dff5bed7 raise /build/glibc-KRRWSm/glibc-2.29/signal/../sysdeps/unix/sysv/linux/raise.c:51:1
 #6 0x00007f16dff3d535 abort /build/glibc-KRRWSm/glibc-2.29/stdlib/abort.c:81:7
 #7 0x00007f16dff3d40f _nl_load_domain /build/glibc-KRRWSm/glibc-2.29/intl/loadmsgcat.c:1177:9
 #8 0x00007f16dff4d012 (/lib/x86_64-linux-gnu/libc.so.6+0x35012)
 #9 0x00000000051a5526 llvm::StructType::getName() const /home/stas/work/llvm/llvm/lib/IR/Type.cpp:0:3
#10 0x0000000003308a8d llvm::Type::getStructName() const /home/stas/work/llvm/llvm/include/llvm/IR/DerivedTypes.h:357:34
#11 0x0000000003300804 llvm::AMDGPU::HSAMD::MetadataStreamerV2::getValueKind(llvm::Type*, llvm::StringRef, llvm::StringRef) const /home/stas/work/llvm/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp:108:36
#12 0x0000000003302201 llvm::AMDGPU::HSAMD::MetadataStreamerV2::emitKernelArg(llvm::Argument const&) /home/stas/work/llvm/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp:362:17
#13 0x0000000003301bfe llvm::AMDGPU::HSAMD::MetadataStreamerV2::emitKernelArgs(llvm::Function const&) /home/stas/work/llvm/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp:306:18
#14 0x0000000003303742 llvm::AMDGPU::HSAMD::MetadataStreamerV2::emitKernel(llvm::MachineFunction const&, llvm::SIProgramInfo const&) /home/stas/work/llvm/llvm/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp:481:3
#15 0x00000000032f6619 llvm::AMDGPUAsmPrinter::EmitFunctionBodyStart() /home/stas/work/llvm/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp:209:1
#16 0x00000000048ec9c4 llvm::AsmPrinter::EmitFunctionBody() /home/stas/work/llvm/llvm/lib/CodeGen/AsmPrinter/AsmPrinter.cpp:1018:3
#17 0x00000000032f8085 llvm::AMDGPUAsmPrinter::runOnMachineFunction(llvm::MachineFunction&) /home/stas/work/llvm/llvm/lib/Target/AMDGPU/AMDGPUAsmPrinter.cpp:465:3
#18 0x0000000004c0c957 llvm::MachineFunctionPass::runOnFunction(llvm::Function&) /home/stas/work/llvm/llvm/lib/CodeGen/MachineFunctionPass.cpp:73:8
#19 0x0000000005110109 llvm::FPPassManager::runOnFunction(llvm::Function&) /home/stas/work/llvm/llvm/lib/IR/LegacyPassManager.cpp:1648:23
#20 0x00000000046430ab (anonymous namespace)::CGPassManager::RunPassOnSCC(llvm::Pass*, llvm::CallGraphSCC&, llvm::CallGraph&, bool&, bool&) /home/stas/work/llvm/llvm/lib/Analysis/CallGraphSCCPass.cpp:176:20
#21 0x00000000046429dc (anonymous namespace)::CGPassManager::RunAllPassesOnSCC(llvm::CallGraphSCC&, llvm::CallGraph&, bool&) /home/stas/work/llvm/llvm/lib/Analysis/CallGraphSCCPass.cpp:441:16
#22 0x0000000004642341 (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) /home/stas/work/llvm/llvm/lib/Analysis/CallGraphSCCPass.cpp:497:18
#23 0x0000000005110cd5 (anonymous namespace)::MPPassManager::runOnModule(llvm::Module&) /home/stas/work/llvm/llvm/lib/IR/LegacyPassManager.cpp:1752:23
#24 0x00000000051107f5 llvm::legacy::PassManagerImpl::run(llvm::Module&) /home/stas/work/llvm/llvm/lib/IR/LegacyPassManager.cpp:1865:16
#25 0x0000000005111251 llvm::legacy::PassManager::run(llvm::Module&) /home/stas/work/llvm/llvm/lib/IR/LegacyPassManager.cpp:1896:3
#26 0x0000000002e3e250 compileModule(char**, llvm::LLVMContext&) /home/stas/work/llvm/llvm/tools/llc/llc.cpp:604:41
#27 0x0000000002e3c8a5 main /home/stas/work/llvm/llvm/tools/llc/llc.cpp:355:13
#28 0x00007f16dff3eb6b __libc_start_main /build/glibc-KRRWSm/glibc-2.29/csu/../csu/libc-start.c:342:3
#29 0x0000000002e3c02a _start (/home/stas/work/llvm/bin/bin/llc+0x2e3c02a)
Aborted (core dumped)
arsenm added inline comments.Jul 3 2019, 2:27 PM
llvm/trunk/lib/Target/AMDGPU/AMDGPUHSAMetadataStreamer.cpp
107–109

You cannot rely on the pointer element type, or the name of IR types

Both tests fail with compiler crashing. Must always check hasName() before using getName().
I believe this needs to be reverted, this change will not work anyway if name was stripped, which llvm does.

Especially Release builds strip all unnecessary names.