This is an archive of the discontinued LLVM Phabricator instance.

[NVPTX] Allow degenerated `nvvm.annotations`
AbandonedPublic

Authored by jdoerfert on Mar 27 2022, 3:18 PM.

Details

Summary

As part of D120129 we started to assert if an nvvm.annotation had a
nullptr as a first component. That is however happening with OpenMP
offload and older CUDA versions, e.g., CUDA 11.0.2, while newer ones,
e.g., 11.4.0 work fine. There is no need to require a non-null value
so let's keep things working for old codes.

Diff Detail

Event Timeline

jdoerfert created this revision.Mar 27 2022, 3:18 PM
jdoerfert requested review of this revision.Mar 27 2022, 3:18 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 27 2022, 3:18 PM
Herald added a subscriber: sstefan1. · View Herald Transcript

Thanks @jdoerfert! I was going to implement a fix for that, but have not managed to do it yet. See a couple of inline comments below.

llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
4273

In D120129, you added a comment containing the following piece of IR:

!nvvm.annotations = !{!8, !9, !8, !10, !10, !10, !10, !11, !11, !10}

!8 = !{null, !"align", i32 8}
!9 = !{null, !"align", i32 8, !"align", i32 65544, !"align", i32 131080}
!10 = !{null, !"align", i32 16}
!11 = !{null, !"align", i32 16, !"align", i32 65552, !"align", i32 131088}

According to that, one piece of metadata can contain more than 3 operands. I was unable to find a piece of code where we create such piece of metadata. I even was ubable to find code that adds align info to nvvm.annotations. All that I have found – NVPTXTargetCodeGenInfo::addNVVMMetadata and similar/duplicating code, that creates a piece of metadata consisting of 3 operands. So, I can’t state for sure without seeing code responsible for that, but given your IR above, a question arises: shouldn’t we change this assert?

llvm/test/CodeGen/NVPTX/param-vectorize-device.ll
803

I think that we should add a comment explaining what is the purpose of these lines. It might be unclear out of the context of the revision. See ; Section X - checking that... comments above.

kovdan01 requested changes to this revision.Mar 27 2022, 6:53 PM
kovdan01 added inline comments.
llvm/lib/Target/NVPTX/NVPTXISelLowering.cpp
4268–4296

During investigation, discovered a nice function bool isKernelFunction(const Function &); in NVPTXUtilities. It does the same thing (with going inside metadata) but correctly in its implementation. So I suppose that we can replace the whole ifndef block with a single asserion:

assert(!isKernelFunction(*F));

Also, if we use an already existing function instead of reinventing a wheel, looks like there is no need in altering tests.

This revision now requires changes to proceed.Mar 27 2022, 6:53 PM
jdoerfert abandoned this revision.Mar 27 2022, 7:47 PM

D120129 needs to be reverted and fixed properly.