Avoid ICE when is_val_statically_known is not of a supported type
This commit is contained in:
parent
af08c64e38
commit
7bdf705dd7
@ -909,6 +909,7 @@ impl<'ll> CodegenCx<'ll, '_> {
|
|||||||
ifn!("llvm.is.constant.isize", fn(t_isize) -> i1);
|
ifn!("llvm.is.constant.isize", fn(t_isize) -> i1);
|
||||||
ifn!("llvm.is.constant.f32", fn(t_f32) -> i1);
|
ifn!("llvm.is.constant.f32", fn(t_f32) -> i1);
|
||||||
ifn!("llvm.is.constant.f64", fn(t_f64) -> i1);
|
ifn!("llvm.is.constant.f64", fn(t_f64) -> i1);
|
||||||
|
ifn!("llvm.is.constant.ptr", fn(ptr) -> i1);
|
||||||
|
|
||||||
ifn!("llvm.expect.i1", fn(i1, i1) -> i1);
|
ifn!("llvm.expect.i1", fn(i1, i1) -> i1);
|
||||||
ifn!("llvm.eh.typeid.for", fn(ptr) -> t_i32);
|
ifn!("llvm.eh.typeid.for", fn(ptr) -> t_i32);
|
||||||
|
@ -119,10 +119,18 @@ impl<'ll, 'tcx> IntrinsicCallMethods<'tcx> for Builder<'_, 'll, 'tcx> {
|
|||||||
sym::likely => {
|
sym::likely => {
|
||||||
self.call_intrinsic("llvm.expect.i1", &[args[0].immediate(), self.const_bool(true)])
|
self.call_intrinsic("llvm.expect.i1", &[args[0].immediate(), self.const_bool(true)])
|
||||||
}
|
}
|
||||||
sym::is_val_statically_known => self.call_intrinsic(
|
sym::is_val_statically_known => {
|
||||||
&format!("llvm.is.constant.{:?}", args[0].layout.immediate_llvm_type(self.cx)),
|
let intrinsic_type = args[0].layout.immediate_llvm_type(self.cx);
|
||||||
&[args[0].immediate()],
|
match self.type_kind(intrinsic_type) {
|
||||||
),
|
TypeKind::Pointer | TypeKind::Integer | TypeKind::Float | TypeKind::Double => {
|
||||||
|
self.call_intrinsic(
|
||||||
|
&format!("llvm.is.constant.{:?}", intrinsic_type),
|
||||||
|
&[args[0].immediate()],
|
||||||
|
)
|
||||||
|
}
|
||||||
|
_ => self.const_bool(false),
|
||||||
|
}
|
||||||
|
}
|
||||||
sym::unlikely => self
|
sym::unlikely => self
|
||||||
.call_intrinsic("llvm.expect.i1", &[args[0].immediate(), self.const_bool(false)]),
|
.call_intrinsic("llvm.expect.i1", &[args[0].immediate(), self.const_bool(false)]),
|
||||||
kw::Try => {
|
kw::Try => {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user