Skip to content

Commit dffa6ac

Browse files
committed
Fix crash after simd type validation error
Fixes part of rust-lang#1319
1 parent 1c724ee commit dffa6ac

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

Diff for: src/intrinsics/mod.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -240,10 +240,9 @@ pub(crate) fn codegen_intrinsic_call<'tcx>(
240240
substs,
241241
args,
242242
destination,
243+
target,
243244
source_info.span,
244245
);
245-
let ret_block = fx.get_block(target);
246-
fx.bcx.ins().jump(ret_block, &[]);
247246
} else if codegen_float_intrinsic_call(fx, intrinsic, args, destination) {
248247
let ret_block = fx.get_block(target);
249248
fx.bcx.ins().jump(ret_block, &[]);

Diff for: src/intrinsics/simd.rs

+8-4
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
2424
_substs: SubstsRef<'tcx>,
2525
args: &[mir::Operand<'tcx>],
2626
ret: CPlace<'tcx>,
27+
target: BasicBlock,
2728
span: Span,
2829
) {
2930
match intrinsic {
@@ -277,16 +278,15 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
277278
} else {
278279
fx.tcx.sess.span_warn(span, "Index argument for `simd_extract` is not a constant");
279280
let trap_block = fx.bcx.create_block();
280-
let dummy_block = fx.bcx.create_block();
281281
let true_ = fx.bcx.ins().iconst(types::I8, 1);
282282
fx.bcx.ins().brnz(true_, trap_block, &[]);
283-
fx.bcx.ins().jump(dummy_block, &[]);
283+
let ret_block = fx.get_block(target);
284+
fx.bcx.ins().jump(ret_block, &[]);
284285
fx.bcx.switch_to_block(trap_block);
285286
crate::trap::trap_unimplemented(
286287
fx,
287288
"Index argument for `simd_extract` is not a constant",
288289
);
289-
fx.bcx.switch_to_block(dummy_block);
290290
return;
291291
};
292292

@@ -876,7 +876,11 @@ pub(super) fn codegen_simd_intrinsic_call<'tcx>(
876876
}
877877

878878
_ => {
879-
fx.tcx.sess.span_fatal(span, &format!("Unknown SIMD intrinsic {}", intrinsic));
879+
fx.tcx.sess.span_err(span, &format!("Unknown SIMD intrinsic {}", intrinsic));
880+
// Prevent verifier error
881+
fx.bcx.ins().trap(TrapCode::UnreachableCodeReached);
880882
}
881883
}
884+
let ret_block = fx.get_block(target);
885+
fx.bcx.ins().jump(ret_block, &[]);
882886
}

0 commit comments

Comments
 (0)