Skip to content

Commit 76be3a0

Browse files
authored
[DirectX] Fix crash in DXILOpBuilder for vector types (#107334)
This function needs to return the "undefined" sigil for unknown types so that the actual error handling triggers instead of a crash.
1 parent 845d8d9 commit 76be3a0

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

llvm/lib/Target/DirectX/DXILOpBuilder.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,8 +123,7 @@ static OverloadKind getOverloadKind(Type *Ty) {
123123
case Type::StructTyID:
124124
return OverloadKind::ObjectType;
125125
default:
126-
llvm_unreachable("invalid overload type");
127-
return OverloadKind::VOID;
126+
return OverloadKind::UNDEFINED;
128127
}
129128
}
130129

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
; RUN: not opt -S -dxil-op-lower -mtriple=dxil-pc-shadermodel6.0-library %s 2>&1 | FileCheck %s
2+
; The sin intrinsic needs to be scalarized before op lowering
3+
4+
; CHECK: error:
5+
; CHECK-SAME: in function sin_vector
6+
; CHECK-SAME: Cannot create Sin operation: Invalid overload type
7+
8+
define <4 x float> @sin_vector(<4 x float> %a) {
9+
%x = call <4 x float> @llvm.sin.v4f32(<4 x float> %a)
10+
ret <4 x float> %x
11+
}

0 commit comments

Comments
 (0)