-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Translate nonsemantic attribute and metadata of GlobalVariable (#2944)
Motivations is similar as f729c49. This PR addresses SYCL device global which may have attributes "sycl-device-image-scope", "sycl-host-access" and "sycl-unique-id". Failure to preserve "sycl-unique-id" after llvm-spirv translation triggers assert at https://github.com/intel/llvm/blob/2824f61dd36790448a224cd596985bd01cbcd0f3/llvm/lib/SYCLLowerIR/DeviceGlobals.cpp#L85 Also preserve GlobalVariable metadata as an improvement, though there is no test to show this is really needed.
- Loading branch information
Showing
7 changed files
with
165 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
test/extensions/KHR/SPV_KHR_non_semantic_info/preserve-gv-attributes.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
; RUN: llvm-as < %s -o %t.bc | ||
; RUN: not llvm-spirv %t.bc -spirv-text --spirv-preserve-auxdata --spirv-max-version=1.5 --spirv-ext=-SPV_KHR_non_semantic_info,+SPV_INTEL_global_variable_decorations -o - 2>&1 | FileCheck %s --check-prefix=CHECK-SPIRV-EXT-DISABLED | ||
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-preserve-auxdata --spirv-max-version=1.5 --spirv-ext=+SPV_INTEL_global_variable_decorations | ||
; RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-EXT | ||
; RUN: llvm-spirv -r --spirv-preserve-auxdata %t.spv -o %t.rev.bc | ||
; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM | ||
; RUN: llvm-spirv -r %t.spv -o %t.rev.without.bc | ||
; RUN: llvm-dis %t.rev.without.bc -o - | FileCheck %s --implicit-check-not="{{foo|bar|baz}}" | ||
|
||
; RUN: llvm-spirv %t.bc -spirv-text --spirv-preserve-auxdata --spirv-ext=+SPV_KHR_non_semantic_info,+SPV_INTEL_global_variable_decorations -o - | FileCheck %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-NOEXT | ||
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-preserve-auxdata --spirv-ext=+SPV_INTEL_global_variable_decorations | ||
; RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-NOEXT | ||
; RUN: llvm-spirv -r --spirv-preserve-auxdata %t.spv -o %t.rev.bc | ||
; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM | ||
; RUN: llvm-spirv -r %t.spv -o %t.rev.without.bc | ||
; RUN: llvm-dis %t.rev.without.bc -o - | FileCheck %s --implicit-check-not="{{foo|bar|baz}}" | ||
|
||
; Check SPIR-V versions in a format magic number + version | ||
; CHECK-SPIRV-EXT: 119734787 65536 | ||
; CHECK-SPIRV-EXT: Extension "SPV_KHR_non_semantic_info" | ||
; CHECK-SPIRV-NOEXT: 119734787 67072 | ||
|
||
; CHECK-SPIRV: ExtInstImport [[#Import:]] "NonSemantic.AuxData" | ||
|
||
; CHECK-SPIRV: String [[#Attr0LHS:]] "sycl-device-global-size" | ||
; CHECK-SPIRV: String [[#Attr0RHS:]] "32" | ||
; CHECK-SPIRV: String [[#Attr1:]] "sycl-device-image-scope" | ||
; CHECK-SPIRV: String [[#Attr2LHS:]] "sycl-host-access" | ||
; CHECK-SPIRV: String [[#Attr2RHS:]] "0" | ||
; CHECK-SPIRV: String [[#Attr3LHS:]] "sycl-unique-id" | ||
; CHECK-SPIRV: String [[#Attr3RHS:]] "_Z20__AsanKernelMetadata" | ||
|
||
; CHECK-SPIRV: Name [[#GVName:]] "__AsanKernelMetadata" | ||
|
||
; CHECK-SPIRV: TypeVoid [[#VoidT:]] | ||
|
||
; CHECK-SPIRV: ExtInst [[#VoidT]] [[#Attr0Inst:]] [[#Import]] NonSemanticAuxDataGlobalVariableAttribute [[#GVName]] [[#Attr0LHS]] [[#Attr0RHS]] {{$}} | ||
; CHECK-SPIRV: ExtInst [[#VoidT]] [[#Attr1Inst:]] [[#Import]] NonSemanticAuxDataGlobalVariableAttribute [[#GVName]] [[#Attr1]] {{$}} | ||
; CHECK-SPIRV: ExtInst [[#VoidT]] [[#Attr1Inst:]] [[#Import]] NonSemanticAuxDataGlobalVariableAttribute [[#GVName]] [[#Attr2LHS]] [[#Attr2RHS]] {{$}} | ||
; CHECK-SPIRV: ExtInst [[#VoidT]] [[#Attr1Inst:]] [[#Import]] NonSemanticAuxDataGlobalVariableAttribute [[#GVName]] [[#Attr3LHS]] [[#Attr3RHS]] {{$}} | ||
|
||
target triple = "spir64-unknown-unknown" | ||
|
||
; CHECK-LLVM: @__AsanKernelMetadata = addrspace(1) global [1 x %structtype] [%structtype { i64 0, i64 92 }] #[[#GVIRAttr:]] | ||
%structtype = type { i64, i64 } | ||
|
||
@__AsanKernelMetadata = addrspace(1) global [1 x %structtype] [%structtype { i64 ptrtoint (ptr addrspace(2) null to i64), i64 92 }], !spirv.Decorations !0 #0 | ||
|
||
; CHECK-LLVM: attributes #[[#GVIRAttr]] = { "sycl-device-global-size"="32" "sycl-device-image-scope" "sycl-host-access"="0" "sycl-unique-id"="_Z20__AsanKernelMetadata" } | ||
attributes #0 = { "sycl-device-global-size"="32" "sycl-device-image-scope" "sycl-host-access"="0" "sycl-unique-id"="_Z20__AsanKernelMetadata" } | ||
|
||
!0 = !{!1} | ||
!1 = !{i32 6147, i32 0, !"_Z20__AsanKernelMetadata"} | ||
|
||
; CHECK-SPIRV-EXT-DISABLED: RequiresExtension: Feature requires the following SPIR-V extension: | ||
; CHECK-SPIRV-EXT-DISABLED-NEXT: SPV_KHR_non_semantic_info |
41 changes: 41 additions & 0 deletions
41
test/extensions/KHR/SPV_KHR_non_semantic_info/preserve-gv-metadata.ll
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
; RUN: llvm-as < %s -o %t.bc | ||
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-preserve-auxdata --spirv-max-version=1.5 | ||
; RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-EXT | ||
; RUN: llvm-spirv -r --spirv-preserve-auxdata %t.spv -o %t.rev.bc | ||
; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM | ||
; RUN: llvm-spirv -r %t.spv -o %t.rev.without.bc | ||
; RUN: llvm-dis %t.rev.without.bc -o - | FileCheck %s --implicit-check-not="{{foo|bar|baz}}" | ||
|
||
; RUN: llvm-spirv %t.bc -o %t.spv --spirv-preserve-auxdata | ||
; RUN: llvm-spirv %t.spv -to-text -o - | FileCheck %s --check-prefixes=CHECK-SPIRV,CHECK-SPIRV-NOEXT | ||
; RUN: llvm-spirv -r --spirv-preserve-auxdata %t.spv -o %t.rev.bc | ||
; RUN: llvm-dis %t.rev.bc -o - | FileCheck %s --check-prefix=CHECK-LLVM | ||
; RUN: llvm-spirv -r %t.spv -o %t.rev.without.bc | ||
; RUN: llvm-dis %t.rev.without.bc -o - | FileCheck %s --implicit-check-not="{{foo|bar|baz}}" | ||
|
||
; Check SPIR-V versions in a format magic number + version | ||
; CHECK-SPIRV-EXT: 119734787 65536 | ||
; CHECK-SPIRV-EXT: Extension "SPV_KHR_non_semantic_info" | ||
; CHECK-SPIRV-NOEXT: 119734787 67072 | ||
|
||
; CHECK-SPIRV: ExtInstImport [[#Import:]] "NonSemantic.AuxData" | ||
|
||
; CHECK-SPIRV: String [[#MDName:]] "absolute_symbol" | ||
|
||
; CHECK-SPIRV: Name [[#GVName:]] "a" | ||
|
||
; CHECK-SPIRV: TypeInt [[#Int32T:]] 64 0 | ||
; CHECK-SPIRV: Constant [[#Int32T]] [[#MDValue0:]] 0 | ||
; CHECK-SPIRV: Constant [[#Int32T]] [[#MDValue1:]] 16 | ||
|
||
; CHECK-SPIRV: TypeVoid [[#VoidT:]] | ||
|
||
; CHECK-SPIRV: ExtInst [[#VoidT]] [[#ValInst:]] [[#Import]] NonSemanticAuxDataGlobalVariableMetadata [[#GVName]] [[#MDName]] [[#MDValue0]] [[#MDValue1]] {{$}} | ||
|
||
target triple = "spir64-unknown-unknown" | ||
|
||
; CHECK-LLVM: @a = external addrspace(1) global i8, !absolute_symbol ![[#LLVMVal:]] | ||
@a = external addrspace(1) global i8, !absolute_symbol !0 | ||
|
||
; CHECK-LLVM: ![[#LLVMVal]] = !{i64 0, i64 16} | ||
!0 = !{i64 0, i64 16} |