Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix OCL builtins translation in case SPV_KHR_untyped_pointers is enabled #2723

Merged
merged 4 commits into from
Oct 8, 2024

Conversation

vmaksimo
Copy link
Contributor

This change allows to preserve the correct builtin mangling in reverse translation.

This change allows to preserve the correct builtin mangling in reverse
translation.
test/transcoding/float16.ll Outdated Show resolved Hide resolved
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM

; RUN: llvm-spirv %t.bc -o %t.spv --spirv-ext=+SPV_KHR_untyped_pointers
Copy link
Contributor

@LU-JOHN LU-JOHN Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How did you pick this file to do additional testing with SPV_KHR_untyped_pointers?
Please add a comment explaining why this additional testing was added.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I'm just running all the tests with the extension enabled and trying to understand where the real fixes should be made, or where we just need to update Checks.
This one is testing OCL builtin so I've checked if we are working fine with them when the extension enabled (turned out that not).
Will add the comment about additional testing though.

@@ -4757,6 +4757,17 @@ Instruction *SPIRVToLLVM::transOCLBuiltinFromExtInst(SPIRVExtInst *BC,
"Not OpenCL extended instruction");

std::vector<Type *> ArgTypes = transTypeVector(BC->getArgTypes(), true);
for (unsigned I = 0; I < ArgTypes.size(); I++) {
Copy link
Contributor

@LU-JOHN LU-JOHN Sep 19, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does function transBuiltinFromInst() also need this special handling? It also calls transTypeVector() and gets a mangled name. Consider putting this special processing within transTypeVector().

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My experiments show that e.g. for OpEnqueKernel we don't meet untyped variables in arguments, but the mangling is still wrong - should be fixed elsewhere.
It's still possible to unify this fix inside transTypeVector(), but not sure if it'd be used by transBuiltinFromInst().

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm fine with the merge as is for now. In general we probably should implement the following algorithm:

  • translate SPIR-V pointer type as LLVM's Typed pointer
  • get the mangling
  • 'opaquefy' the pointer to construct the function and call instruction

Copy link
Contributor

@MrSidims MrSidims left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

@MrSidims MrSidims requested a review from svenvh October 7, 2024 12:26
@MrSidims MrSidims merged commit 33150bf into KhronosGroup:main Oct 8, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants