This is an archive of the discontinued LLVM Phabricator instance.

[NVPTX] Remove image/sampler special case in call lowering
ClosedPublic

Authored by nikic on Feb 8 2022, 3:27 AM.

Details

Summary

I suspect that this is dead code. There is no test coverage for this special case, and the struct type names this checks against don't seem to match what OpenCL actually generates (which would be %opencl.sampler_t rather than %struct._sampler_t for example).

Motivation for this change is that this code is incompatible with opaque pointers -- simply deleting it is the simplest way of making it compatible :)

Diff Detail

Event Timeline

nikic created this revision.Feb 8 2022, 3:27 AM
nikic requested review of this revision.Feb 8 2022, 3:27 AM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 8 2022, 3:27 AM
tra added a comment.Feb 8 2022, 11:21 AM

I have absolutely no idea what OpenCL does with sample/texture handles. You may want to find whoever added the code.

I do see that Apple's xcode SDK 13.2.1 still uses struct _image2d_t and _image3d_t in macosx/System/Library/Frameworks/OpenCL.framework/Versions/A/lib/clang/3.2/include/cl_kernel.h
That said, I think NVIDIA has stopped supporting macs a while back, so it's probably not very relevant.

nikic added a comment.Feb 8 2022, 11:49 AM

I have absolutely no idea what OpenCL does with sample/texture handles. You may want to find whoever added the code.

This code exists since the NVPTX backend was first merged, and it looks like the person who added it hasn't been active in many years.

Poking around a bit, I suspect that this is now handled in a different way by this code: https://github.com/llvm/llvm-project/blob/f231599666c7bf93086fe9b1d6687d62355d2871/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp#L1400-L1431

tra accepted this revision.Feb 8 2022, 12:31 PM

I have absolutely no idea what OpenCL does with sample/texture handles. You may want to find whoever added the code.

This code exists since the NVPTX backend was first merged, and it looks like the person who added it hasn't been active in many years.

Poking around a bit, I suspect that this is now handled in a different way by this code: https://github.com/llvm/llvm-project/blob/f231599666c7bf93086fe9b1d6687d62355d2871/llvm/lib/Target/NVPTX/NVPTXAsmPrinter.cpp#L1400-L1431

That code also came with the initial drop of NVPTX back-end: https://github.com/llvm/llvm-project/blame/f231599666c7bf93086fe9b1d6687d62355d2871/llvm/lib/Target/NVPTX/NVPTXUtilities.cpp#L158

Considering that handles do need special handling, it looks to me that OpenCL targeting NVPTX may be currently broken.
That leaves potential external IR users that may depend on this argument lowering. Googling for struct._image2d_t suggests that there are none as there are only a few references, most of them pointing back at LLVM.

Let's land it and see what happens.

This revision is now accepted and ready to land.Feb 8 2022, 12:31 PM
This revision was automatically updated to reflect the committed changes.