Skip to content

Commit 23cce6e

Browse files
committed
Translate OpUndef to poison instead of undef in SPIR-V reader
1 parent 787f1e7 commit 23cce6e

File tree

10 files changed

+55
-52
lines changed

10 files changed

+55
-52
lines changed

lib/SPIRV/SPIRVReader.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1704,7 +1704,7 @@ Value *SPIRVToLLVM::transValueWithoutDecoration(SPIRVValue *BV, Function *F,
17041704
}
17051705

17061706
case OpUndef:
1707-
return mapValue(BV, UndefValue::get(transType(BV->getType())));
1707+
return mapValue(BV, PoisonValue::get(transType(BV->getType())));
17081708

17091709
case OpSizeOf: {
17101710
Type *ResTy = transType(BV->getType());

test/DebugInfo/DebugInfoLLVMArg.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ entry:
6565
; CHECK-LLVM-OCL: #dbg_value(!DIArgList(ptr %x), ![[#]], !DIExpression(DW_OP_LLVM_arg, 0), ![[#]])
6666
; CHECK-LLVM-200: #dbg_value(!DIArgList(ptr %x), ![[#]], !DIExpression(DW_OP_LLVM_arg, 0), ![[#]])
6767
call void @llvm.dbg.value(metadata !DIArgList(ptr %x), metadata !6, metadata !DIExpression(DW_OP_LLVM_arg, 0)), !dbg !10
68-
; CHECK-LLVM-OCL: #dbg_value(ptr undef, ![[#]], !DIExpression(), ![[#]])
68+
; CHECK-LLVM-OCL: #dbg_value(ptr poison, ![[#]], !DIExpression(), ![[#]])
6969
; CHECK-LLVM-200: #dbg_value(!DIArgList(ptr %x, ptr %x), ![[#]], !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus)
7070
call void @llvm.dbg.value(metadata !DIArgList(ptr %x, ptr %x), metadata !6, metadata !DIExpression(DW_OP_LLVM_arg, 0, DW_OP_LLVM_arg, 1, DW_OP_plus)), !dbg !10
7171
store i32 42, ptr %x, align 4

test/complex-constexpr-vector.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ entry:
5656
; CHECK-LLVM-SAME: i8 add (
5757
; CHECK-LLVM-SAME: i8 extractelement (<8 x i8> bitcast (<2 x i32> splat (i32 65793) to <8 x i8>), i32 2),
5858
; CHECK-LLVM-SAME: i8 extractelement (<8 x i8> bitcast (<2 x i32> splat (i32 131586) to <8 x i8>), i32 2)),
59-
; CHECK-LLVM-SAME: i8 undef>,
59+
; CHECK-LLVM-SAME: i8 poison>,
6060
; CHECK-LLVM-SAME: ![[#]], !DIExpression(), ![[#]])
6161

6262
; CHECK-LLC: target triple = "spir64-unknown-unknown"

test/freeze.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ define spir_func i64 @testfunction_ptrB(ptr addrspace(1) %val) {
125125
}
126126

127127
; CHECK-LLC: @testfunction_ptrB
128-
; CHECK-LLC-NEXT: ptrtoint ptr undef to i64
128+
; CHECK-LLC-NEXT: ptrtoint ptr poison to i64
129129

130130
; CHECK-LLVM: @testfunction_ptrC
131131
; Frozen poison/undef should produce a constant.
@@ -138,4 +138,4 @@ define spir_func i64 @testfunction_ptrC(ptr addrspace(1) %val) {
138138
}
139139

140140
; CHECK-LLC: @testfunction_ptrC
141-
; CHECK-LLC-NEXT: ptrtoint ptr undef to i64
141+
; CHECK-LLC-NEXT: ptrtoint ptr poison to i64

test/global-var-name-linkage.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ target triple = "spir64-unknown-unknown"
4545
; CHECK-DAG: Decorate [[#id38]] Constant
4646
; CHECK-DAG: Decorate [[#id38]] Alignment 4
4747

48-
; CHECK-LLVM: @G1 = internal addrspace(1) constant %"class.sycl::_V1::nd_item" undef, align 1
48+
; CHECK-LLVM: @G1 = internal addrspace(1) constant %"class.sycl::_V1::nd_item" poison, align 1
4949
; CHECK-LLVM: @g1 = addrspace(1) global i32 1, align 4
5050
; CHECK-LLVM: @g2 = internal addrspace(1) global i32 2, align 4
5151
; CHECK-LLVM: @g4 = common addrspace(1) global i32 0, align 4

test/llvm-intrinsics/frexp.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ define { float, i32 } @frexp_negzero() {
8080
}
8181

8282
; CHECK-SPIRV: ExtInst [[#TypeDouble]] [[#]] [[#ExtInstSetId]] frexp [[#UndefDouble]] [[#]]
83-
; CHECK-LLVM: call spir_func double @_Z5frexpdPi(double undef, ptr %[[#]])
83+
; CHECK-LLVM: call spir_func double @_Z5frexpdPi(double poison, ptr %[[#]])
8484
; CHECK-LLVM: ret %[[StrTypeDoubleInt]]
8585
define { double, i32 } @frexp_undef() {
8686
%ret = call { double, i32 } @llvm.frexp.f64.i32(double undef)
@@ -104,7 +104,7 @@ define { <2 x float>, <2 x i32> } @frexp_zero_negzero_vector() {
104104
}
105105

106106
; CHECK-SPIRV: ExtInst [[#VecFloat4]] [[#]] [[#ExtInstSetId]] frexp [[#]] [[#]]
107-
; CHECK-LLVM: call spir_func <4 x float> @_Z5frexpDv4_fPDv4_i(<4 x float> <float 1.600000e+01, float -3.200000e+01, float undef, float 9.999000e+03>, ptr %[[#]])
107+
; CHECK-LLVM: call spir_func <4 x float> @_Z5frexpDv4_fPDv4_i(<4 x float> <float 1.600000e+01, float -3.200000e+01, float poison, float 9.999000e+03>, ptr %[[#]])
108108
; CHECK-LLVM: ret %[[StrTypeFloatIntVec4]]
109109
define { <4 x float>, <4 x i32> } @frexp_nonsplat_vector() {
110110
%ret = call { <4 x float>, <4 x i32> } @llvm.frexp.v4f32.v4i32(<4 x float> <float 16.0, float -32.0, float undef, float 9999.0>)

test/opundef.spt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,10 +45,10 @@
4545

4646
; CHECK: define spir_func %structtype @foo() #0 {
4747
; CHECK-NEXT: entry:
48-
; CHECK-NEXT: ret %structtype { i32 1, float undef }
48+
; CHECK-NEXT: ret %structtype { i32 1, float poison }
4949
; CHECK-NEXT: }
5050
; CHECK: define spir_func %structtype @bar() #0 {
5151
; CHECK-NEXT: entry:
52-
; CHECK-NEXT: ret %structtype { i32 1, float undef }
52+
; CHECK-NEXT: ret %structtype { i32 1, float poison }
5353
; CHECK-NEXT: }
5454

test/transcoding/image_signedness_spv_ir.ll

Lines changed: 39 additions & 39 deletions
Large diffs are not rendered by default.

test/transcoding/undef_initializer.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ entry:
2222
; CHECK-SPIRV: {{[0-9]+}} Undef {{[0-9]+}} [[UNDEF_ID:[0-9]+]]
2323
; CHECK-SPIRV: {{[0-9]+}} ConstantComposite {{[0-9]+}} [[CC_ID:[0-9]+]] [[UNDEF_ID]]
2424
; CHECK-SPIRV: {{[0-9]+}} Variable {{[0-9]+}} {{[0-9]+}} {{[0-9]+}} [[CC_ID]]
25-
; CHECK-LLVM: @__const.struct = internal addrspace(2) constant %struct.my_struct undef, align 1
25+
; CHECK-LLVM: @__const.struct = internal addrspace(2) constant %struct.my_struct poison, align 1
2626

2727
!llvm.module.flags = !{!1}
2828
!opencl.ocl.version = !{!2}

test/var_undef.ll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,10 @@
77
; RUN: llvm-spirv -r %t.spv -o %t.rev.bc
88
; RUN: llvm-dis %t.rev.bc -o %t.rev.ll
99
; RUN: FileCheck < %t.rev.ll %s --check-prefix CHECK-LLVM
10-
; FIXME: FILECHECK_FAIL during llvm-spirv -r in llc compilation flow
10+
; RUN: %if spirv-backend %{ llc -O0 -mtriple=spirv64-unknown-unknown -filetype=obj %s -o %t.llc.spv %}
11+
; RUN: %if spirv-backend %{ llvm-spirv -r %t.llc.spv -o %t.llc.rev.bc %}
12+
; RUN: %if spirv-backend %{ llvm-dis %t.llc.rev.bc -o %t.llc.rev.ll %}
13+
; RUN: %if spirv-backend %{ FileCheck %s --input-file %t.llc.rev.ll --check-prefix CHECK-LLVM %}
1114

1215
; CHECK-SPIRV: Name [[FOO_VAR:[0-9]+]] "foo"
1316
; CHECK-SPIRV: Name [[BAR_VAR:[0-9]+]] "bar"
@@ -17,7 +20,7 @@
1720
;; word count must be 4
1821
; CHECK-SPIRV: 4 Variable [[#]] [[BAR_VAR]]
1922

20-
; CHECK-LLVM: @foo = internal addrspace(3) global %anon undef, align 8
23+
; CHECK-LLVM: @foo = internal addrspace(3) global %anon poison, align 8
2124
; CHECK-LLVM: @bar = internal addrspace(3) global %range poison, align 8
2225

2326
target datalayout = "e-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024-n8:16:32:64"

0 commit comments

Comments
 (0)