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

Use demangled name for BuiltinWithGenericPointer #1344

Merged
merged 2 commits into from
May 13, 2024

Conversation

bmanga
Copy link
Contributor

@bmanga bmanga commented May 6, 2024

This tries to address #1343

@rjodinchr should I also add a test?

Copy link

google-cla bot commented May 6, 2024

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@rjodinchr
Copy link
Collaborator

should I also add a test?

It would be great to add the simple example you gave in the issue. Maybe just running clang front-end as in https://github.com/google/clspv/blob/main/test/emit_ir.cl#L1

@bmanga bmanga marked this pull request as draft May 7, 2024 00:39
@bmanga bmanga marked this pull request as ready for review May 7, 2024 00:49
lib/Builtins.cpp Outdated Show resolved Hide resolved
lib/Builtins.cpp Outdated Show resolved Hide resolved
test/BuiltinsWithGenericPointer/issue-1343.cl Outdated Show resolved Hide resolved
test/BuiltinsWithGenericPointer/issue-1343.cl Show resolved Hide resolved
@bmanga
Copy link
Contributor Author

bmanga commented May 7, 2024

If I add the --output-format=ll to the test file then the error is not triggered as I think it happens at a later stage.
Keeping the test file as I had it originally gives (for the original code):

FAIL: clspv :: BuiltinsWithGenericPointer/issue-1343.cl (1 of 12)
******************** TEST 'clspv :: BuiltinsWithGenericPointer/issue-1343.cl' FAILED ********************
Exit Code: 255

Command Output (stdout):
--
# RUN: at line 1
clspv --cl-std=CLC++ --inline-entry-points  /home/bruno/Projects/clspv/test/BuiltinsWithGenericPointer/issue-1343.cl -o /home/bruno/Projects/clspv/build/test/BuiltinsWithGenericPointer/Output/issue-1343.cl.tmp.spv
# executed command: clspv --cl-std=CLC++ --inline-entry-points /home/bruno/Projects/clspv/test/BuiltinsWithGenericPointer/issue-1343.cl -o /home/bruno/Projects/clspv/build/test/BuiltinsWithGenericPointer/Output/issue-1343.cl.tmp.spv
# .---command stderr------------
# | /home/bruno/Projects/clspv/test/BuiltinsWithGenericPointer/issue-1343.cl:4:7: warning: no previous prototype for function 'contains_frexp_in_name'
# |     4 | float contains_frexp_in_name(float, int *) {}
# |       |       ^
# | /home/bruno/Projects/clspv/test/BuiltinsWithGenericPointer/issue-1343.cl:4:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
# |     4 | float contains_frexp_in_name(float, int *) {}
# |       | ^
# |       | static 
# | /home/bruno/Projects/clspv/test/BuiltinsWithGenericPointer/issue-1343.cl:4:45: warning: non-void function does not return a value
# |     4 | float contains_frexp_in_name(float, int *) {}
# |       |                                             ^
# | /home/bruno/Projects/clspv/test/BuiltinsWithGenericPointer/issue-1343.cl:6:6: warning: no previous prototype for function 'vstore_half5'
# |     6 | void vstore_half5(float2, size_t, half *) {}
# |       |      ^
# | /home/bruno/Projects/clspv/test/BuiltinsWithGenericPointer/issue-1343.cl:6:1: note: declare 'static' if the function is not intended to be used outside of this translation unit
# |     6 | void vstore_half5(float2, size_t, half *) {}
# |       | ^
# |       | static 
# | target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-G1"; Function Attrs: convergent mustprogress norecurse nounwind
# | define dso_local spir_func float @_Z22contains_frexp_in_namefPi(float %0, ptr %1)
# | ; Function Attrs: convergent mustprogress norecurse nounwind
# | define dso_local spir_func float @_Z22contains_frexp_in_namefPU3AS1i(float %0, ptr addrspace(1) %1)
# | ; Function Attrs: convergent mustprogress norecurse nounwind
# | define dso_local spir_func float @_Z22contains_frexp_in_namefPU3AS3i(float %0, ptr addrspace(3) %1)
# | @clspv.builtins.used = appending global [3 x ptr] [ptr @_Z22contains_frexp_in_namefPi, ptr @_Z22contains_frexp_in_namefPU3AS1i, ptr @_Z22contains_frexp_in_namefPU3AS3i], section "llvm.metadata"
# | internal_additional_library:: error: expected '{' in function body
# | define dso_local spir_func float @_Z22contains_frexp_in_namefPU3AS1i(float %0, ptr addrspace(1) %1)
# | ^
# `-----------------------------
# error: command failed with exit status: 255

--

And passes with the PR changes.

I think it should be good enough?

@rjodinchr
Copy link
Collaborator

We don't like adding a test without explicit checks. It makes it quite complicated sometimes when it starts failing for whatever reason to know what the test was expecting to check.

As it's the link that is failing and it is performed after the GenerateIRFile, it makes sense that it does not work with --output-format.
What we can do instead is to use --print-before=annotation-to-metadata to get the ll file after the link. So that we can check that the content is what we expect and nothing more.

@bmanga
Copy link
Contributor Author

bmanga commented May 7, 2024

Mh I've tried that and it seems like clspv crashes before being able to dump anything to the file...

@rjodinchr
Copy link
Collaborator

Without the fix, it should crash before anything is dumped. Am I missing something?

@bmanga
Copy link
Contributor Author

bmanga commented May 9, 2024

Ah ok I misunderstood your previous comment. I thought you wanted the test to fail through FileCheck and I assumed that flag would output something I could act upon without crashing the compiler.

Updated. Let me know if that's ok :)

@rjodinchr rjodinchr merged commit a359357 into google:main May 13, 2024
12 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.

None yet

3 participants