Implement black_box
using intrinsic
The new implementation allows some `memcpy`s to be optimized away, so the uninit value in ui/sanitize/memory.rs is constructed directly onto the return place. Therefore the sanitizer now says that the value is allocated by `main` rather than `random`.
This commit is contained in:
parent
ae90dcf020
commit
1fb1643129
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