Skip to content

Commit 3069557

Browse files
franzpreethi-intel
authored andcommitted
Fix parsing of --spec-const option (intel#1630)
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(). Original commit: KhronosGroup/SPIRV-LLVM-Translator@1103477
1 parent f7b72c5 commit 3069557

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

llvm-spirv/test/transcoding/spec_const.ll

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
; RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefix=CHECK-SPIRV
55
; RUN: llvm-spirv -r -emit-opaque-pointers %t.spv -o %t.rev.bc
66
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
7-
; RUN: llvm-spirv -r -emit-opaque-pointers -spec-const "0:i1:1 1:i8:11 2:i16:22 3:i32:33 4:i64:44 5:f16:5.5 6:f32:6.6 7:f64:7.7" %t.spv -o %t.rev.spec.bc
7+
; RUN: llvm-spirv -r -emit-opaque-pointers -spec-const "0:i1:1 1:i8:11 2:i16:22 3:i32:33 4:i64:4609589727908835759 5:f16:5.5 6:f32:6.6 7:f64:7.7" %t.spv -o %t.rev.spec.bc
88
; RUN: llvm-dis < %t.rev.spec.bc | FileCheck %s --check-prefix=CHECK-LLVM-SPEC
99

1010
; CHECK-SPIRV-NOT: Capability Matrix
@@ -56,7 +56,7 @@ entry:
5656
store i32 %3, i32 addrspace(1)* %i, align 4
5757

5858
; CHECK-LLVM: store i64 3, ptr addrspace(1) %l, align 8
59-
; CHECK-LLVM-SPEC: store i64 44, ptr addrspace(1) %l, align 8
59+
; CHECK-LLVM-SPEC: store i64 4609589727908835759, ptr addrspace(1) %l, align 8
6060
%4 = call i64 @_Z20__spirv_SpecConstantix(i32 4, i64 3)
6161
store i64 %4, i64 addrspace(1)* %l, align 8
6262

llvm-spirv/tools/llvm-spirv/llvm-spirv.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -588,7 +588,7 @@ bool parseSpecConstOpt(llvm::StringRef SpecConstStr,
588588
}
589589
APInt Value;
590590
bool Err = Params[2].getAsInteger(10, Value);
591-
if (Err || Value.getNumWords() > 1 ||
591+
if (Err || Value.getActiveWords() > 1 ||
592592
(Width < 64 && Value.getZExtValue() >> Width)) {
593593
errs() << "Error: Invalid value for '-" << SpecConst.ArgStr
594594
<< "' option! In \"" << Option << "\": can't convert \""

0 commit comments

Comments
 (0)