Skip to content

Commit 0fce02b

Browse files
committed
Revert "Deprecate SPV_INTEL_hw_thread_queries extension from forward llvm-spirv (#3130)"
This reverts commit 6495e45.
1 parent cb4c187 commit 0fce02b

File tree

6 files changed

+83
-16
lines changed

6 files changed

+83
-16
lines changed

llvm-spirv/README.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -273,8 +273,7 @@ should disable support for forward translation of the extension in the main bran
273273
(this will prevent new SPIR-V modules from being generated using the extension).
274274
Meanwhile support reverse translation for the extension should be continued
275275
(this retains compatibility with existing SPIR-V modules).
276-
* Addition of deprecation warning for the extension is not required, yet recommended for extensions adding
277-
instructions representable in LLVM IR only via SPIR-V friendly LLVM IR.
276+
* Addition of deprecation warning for the extension is not required.
278277
* We encourage backporting the changes to other branches to speed up removal, but this is not required.
279278
280279
After at least one release cycle one may remove support for reverse translation in the main branch as well,

llvm-spirv/lib/SPIRV/SPIRVWriter.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2155,11 +2155,14 @@ LLVMToSPIRVBase::transValueWithoutDecoration(Value *V, SPIRVBasicBlock *BB,
21552155
if (static_cast<uint32_t>(Builtin) >= internal::BuiltInSubDeviceIDINTEL &&
21562156
static_cast<uint32_t>(Builtin) <=
21572157
internal::BuiltInGlobalHWThreadIDINTEL) {
2158-
std::string ErrorStr = "SPV_INTEL_hw_thread_queries\n"
2159-
"Please report to "
2160-
"https://github.com/intel/llvm in case if you see "
2161-
"this error.\nRef LLVM Value:";
2162-
getErrorLog().checkError(false, SPIRVEC_DeprecatedExtension, V, ErrorStr);
2158+
if (!BM->isAllowedToUseExtension(
2159+
ExtensionID::SPV_INTEL_hw_thread_queries)) {
2160+
std::string ErrorStr = "Intel HW thread queries must be enabled by "
2161+
"SPV_INTEL_hw_thread_queries extension.\n"
2162+
"LLVM value that is being translated:\n";
2163+
getErrorLog().checkError(false, SPIRVEC_InvalidModule, V, ErrorStr);
2164+
}
2165+
BM->addExtension(ExtensionID::SPV_INTEL_hw_thread_queries);
21632166
}
21642167

21652168
BVar->setBuiltin(Builtin);

llvm-spirv/lib/SPIRV/libSPIRV/SPIRVErrorEnum.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,6 @@ _SPIRV_OP(UnspecifiedMemoryModel, "Unspecified Memory Model.")
2828
_SPIRV_OP(RepeatedMemoryModel, "Expects a single OpMemoryModel instruction.")
2929
_SPIRV_OP(UnsupportedVarArgFunction,
3030
"Variadic functions other than 'printf' are not supported in SPIR-V.")
31-
_SPIRV_OP(DeprecatedExtension,
32-
"Feature requires the following deprecated SPIR-V extension:\n")
3331

3432
/* This is the last error code to have a maximum valid value to compare to */
3533
_SPIRV_OP(InternalMaxErrorCode, "Unknown error code")
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
; Test for SPV_INTEL_hw_thread_queries feature
2+
; SPIR-V friendly LLVM IR to SPIR-V translation and vice versa
3+
; RUN: llvm-as %s -o %t.bc
4+
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_hw_thread_queries -o %t.spv
5+
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
6+
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
7+
8+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
9+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
10+
; RUN: llvm-spirv -r --spirv-target-env=SPV-IR %t.spv -o %t.rev.bc
11+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
12+
13+
; CHECK-SPIRV: Capability HWThreadQueryINTEL
14+
; CHECK-SPIRV: Extension "SPV_INTEL_hw_thread_queries"
15+
; CHECK-SPIRV: Decorate [[#Id1:]] BuiltIn 6135
16+
; CHECK-SPIRV: Decorate [[#Id2:]] BuiltIn 6136
17+
; CHECK-SPIRV: Variable [[#]] [[#Id1]]
18+
; CHECK-SPIRV: Variable [[#]] [[#Id2]]
19+
20+
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"
21+
target triple = "spir-unknown-unknown"
22+
23+
; Function Attrs: nounwind readnone
24+
define spir_kernel void @foo() {
25+
entry:
26+
%0 = call spir_func i32 @_Z31__spirv_BuiltInSubDeviceIDINTELv() #1
27+
%1 = call spir_func i32 @_Z36__spirv_BuiltInGlobalHWThreadIDINTELv() #1
28+
; CHECK-LLVM: call spir_func i32 @_Z31__spirv_BuiltInSubDeviceIDINTELv() #1
29+
; CHECK-LLVM: call spir_func i32 @_Z36__spirv_BuiltInGlobalHWThreadIDINTELv() #1
30+
ret void
31+
}
32+
33+
declare dso_local spir_func i32 @_Z31__spirv_BuiltInSubDeviceIDINTELv()
34+
35+
declare dso_local spir_func i32 @_Z36__spirv_BuiltInGlobalHWThreadIDINTELv()
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
; Test for SPV_INTEL_hw_thread_queries feature
2+
; SPIR-V friendly LLVM IR to SPIR-V translation and vice versa
3+
; RUN: llvm-as %s -o %t.bc
4+
; RUN: llvm-spirv %t.bc --spirv-ext=+SPV_INTEL_hw_thread_queries -o %t.spv
5+
; RUN: llvm-spirv %t.spv -to-text -o %t.spt
6+
; RUN: FileCheck < %t.spt %s --check-prefix=CHECK-SPIRV
7+
8+
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
9+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
10+
; RUN: llvm-spirv -r --spirv-target-env=SPV-IR %t.spv -o %t.rev.bc
11+
; RUN: llvm-dis < %t.rev.bc | FileCheck %s --check-prefix=CHECK-LLVM
12+
13+
; CHECK-SPIRV: Capability HWThreadQueryINTEL
14+
; CHECK-SPIRV: Extension "SPV_INTEL_hw_thread_queries"
15+
; CHECK-SPIRV: Decorate [[#Id1:]] BuiltIn 6135
16+
; CHECK-SPIRV: Decorate [[#Id2:]] BuiltIn 6136
17+
; CHECK-SPIRV: Variable [[#]] [[#Id1]]
18+
; CHECK-SPIRV: Variable [[#]] [[#Id2]]
19+
20+
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"
21+
target triple = "spir-unknown-unknown"
22+
23+
@__spirv_BuiltInSubDeviceIDINTEL = external addrspace(1) global i32
24+
@__spirv_BuiltInGlobalHWThreadIDINTEL = external addrspace(1) global i32
25+
26+
; Function Attrs: nounwind readnone
27+
define spir_kernel void @foo() {
28+
entry:
29+
%0 = load i32, ptr addrspace(4) addrspacecast (ptr addrspace(1) @__spirv_BuiltInSubDeviceIDINTEL to ptr addrspace(4)), align 4
30+
%1 = load i32, ptr addrspace(4) addrspacecast (ptr addrspace(1) @__spirv_BuiltInGlobalHWThreadIDINTEL to ptr addrspace(4)), align 4
31+
; CHECK-LLVM: call spir_func i32 @_Z31__spirv_BuiltInSubDeviceIDINTELv() #1
32+
; CHECK-LLVM: call spir_func i32 @_Z36__spirv_BuiltInGlobalHWThreadIDINTELv() #1
33+
ret void
34+
}

llvm-spirv/test/extensions/INTEL/SPV_INTEL_hw_thread_queries/negative_intel_hw_thread_queries.ll

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
; Deprecation test for SPV_INTEL_hw_thread_queries extension.
2-
; Check for errors in case if LLVM IR module contains HW thread queries as a for of
3-
; SPIR-V friendly LLVM IR.
1+
; Negative test for SPV_INTEL_hw_thread_queries feature
2+
; Check for errors in case if the extension is not enabled, but the appropriate
3+
; SPV-IR patter is found
44
; RUN: llvm-as %s -o %t.bc
55
; RUN: not llvm-spirv %t.bc -o %t.spv 2>&1 | FileCheck %s
66

7-
; CHECK: DeprecatedExtension: Feature requires the following deprecated SPIR-V extension:
8-
; CHECK: SPV_INTEL_hw_thread_queries
9-
; CHECK: Please report to https://github.com/intel/llvm in case if you see this error.
10-
; CHECK: Ref LLVM Value:
7+
; CHECK: InvalidModule: Invalid SPIR-V module: Intel HW thread queries must be enabled by SPV_INTEL_hw_thread_queries extension.
8+
; CHECK: LLVM value that is being translated:
119
; CHECK: @__spirv_BuiltInSubDeviceIDINTEL = external addrspace(1) global i32
1210

1311
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"

0 commit comments

Comments
 (0)