Rollup merge of #87916 - nbdd0121:black_box, r=nagisa
Implement `black_box` using intrinsic Introduce `black_box` intrinsic, as suggested in https://github.com/rust-lang/rust/pull/87590#discussion_r680468700. This is still codegenned as empty inline assembly for LLVM. For MIR interpretation and cranelift it's treated as identity. cc `@Amanieu` as this is related to inline assembly cc `@bjorn3` for rustc_codegen_cranelift changes cc `@RalfJung` as this affects MIRI r? `@nagisa` I suppose
This commit is contained in:
commit
df23264f80
9 changed files with 52 additions and 15 deletions
|
@ -102,6 +102,7 @@ pub fn intrinsic_operation_unsafety(intrinsic: Symbol) -> hir::Unsafety {
|
|||
| sym::maxnumf64
|
||||
| sym::type_name
|
||||
| sym::forget
|
||||
| sym::black_box
|
||||
| sym::variant_count => hir::Unsafety::Normal,
|
||||
_ => hir::Unsafety::Unsafe,
|
||||
}
|
||||
|
@ -387,6 +388,8 @@ pub fn check_intrinsic_type(tcx: TyCtxt<'_>, it: &hir::ForeignItem<'_>) {
|
|||
(1, vec![param_ty; 2], tcx.types.bool)
|
||||
}
|
||||
|
||||
sym::black_box => (1, vec![param(0)], param(0)),
|
||||
|
||||
other => {
|
||||
tcx.sess.emit_err(UnrecognizedIntrinsicFunction { span: it.span, name: other });
|
||||
return;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue