1
Fork 0

Rollup merge of #122287 - RalfJung:simd-static-assert, r=pnkfelix

add test ensuring simd codegen checks don't run when a static assertion failed

stdarch relies on this to ensure that SIMD indices are in bounds.

I would love to know why this works, but I can't figure out where codegen decides to not codegen a function if a required-const does not evaluate. `@oli-obk` `@bjorn3` do you have any idea?
This commit is contained in:
Matthias Krüger 2024-03-14 15:44:33 +01:00 committed by GitHub
commit 6a4dd19ade
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 56 additions and 8 deletions

View file

@ -21,11 +21,11 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
}
pub fn eval_mir_constant(&self, constant: &mir::ConstOperand<'tcx>) -> mir::ConstValue<'tcx> {
// `MirUsedCollector` visited all constants before codegen began, so if we got here there
// can be no more constants that fail to evaluate.
// `MirUsedCollector` visited all required_consts before codegen began, so if we got here
// there can be no more constants that fail to evaluate.
self.monomorphize(constant.const_)
.eval(self.cx.tcx(), ty::ParamEnv::reveal_all(), Some(constant.span))
.expect("erroneous constant not captured by required_consts")
.expect("erroneous constant missed by mono item collection")
}
/// This is a convenience helper for `simd_shuffle_indices`. It has the precondition

View file

@ -211,7 +211,8 @@ pub fn codegen_mir<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>>(
// It may seem like we should iterate over `required_consts` to ensure they all successfully
// evaluate; however, the `MirUsedCollector` already did that during the collection phase of
// monomorphization so we don't have to do it again.
// monomorphization, and if there is an error during collection then codegen never starts -- so
// we don't have to do it again.
fx.per_local_var_debug_info = fx.compute_per_local_var_debug_info(&mut start_bx);