Skip to content

Conversation

@franz
Copy link
Contributor

@franz franz commented Sep 28, 2022

While running OpenCL-CTS SPIR-V subtests, i found that launching llvm-spirv with arguments:

-r --spec-const=101:i64:4609589727908835759

results in error message:

Error: Invalid value for '-spec-const' option! In "101:i64:4609589727908835759": can't convert "4609589727908835759" to 64-bit integer number

However, 4609589727908835759 fits into 64bits (0x3ff88d6f544bb1af). The problem seems to be that getNumWords() returns 2 so i changed it to use getActiveBits(), but i'm not 100% sure this is the proper fix.

launching llvm-spirv with arguments:

-r --spec-const=101:i64:4609589727908835759

results in error message:

Error: Invalid value for '-spec-const' option! In "101:i64:4609589727908835759": can't convert "4609589727908835759" to 64-bit integer number

However, 4609589727908835759 fits into 64bits. The problem is that getNumWords() returns 2
so instead change the check to use getActiveBits()
@CLAassistant
Copy link

CLAassistant commented Sep 28, 2022

CLA assistant check
All committers have signed the CLA.

@MrSidims
Copy link
Contributor

Thanks for the report and the PR, that is very appreciated! Could you please add a small test (may be modify transcoding/spec_const.ll ) so we can ensure, that the issue is gone? TBH I'm very surprised by the fact, that getNumWords() returns 2 for 4609589727908835759 .

Copy link
Member

@svenvh svenvh left a comment

Choose a reason for hiding this comment

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

TBH I'm very surprised by the fact, that getNumWords() returns 2 for 4609589727908835759 .

Me too, so I did a little investigation. It turns out StringRef::getAsInteger deliberately overestimates the required number of bits based on the radix and the string length.

So getActiveWords is the right method to use here. Thanks for the fix!

@MrSidims MrSidims merged commit 1103477 into KhronosGroup:main Sep 30, 2022
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