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

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

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
@@ -2003,6 +2003,12 @@ class SPIRVExtInst : public SPIRVFunctionCallGeneric<OpExtInst, 5> {
}
return VArgs;
}
SPIRVValue *getArg(SPIRVWord I) {
Copy link
Contributor

Choose a reason for hiding this comment

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

I think this should be renamed getArgValue to be consistent with the pre-existing getArgValues which returns a vector pointers. Also, consider implementing getArgValues with getArgValue.

; 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().

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.

2 participants