1 use std::{collections::hash_map::Entry, iter};
5 use rustc_apfloat::Float;
6 use rustc_ast::expand::allocator::AllocatorKind;
9 def_id::{CrateNum, DefId, LOCAL_CRATE},
11 use rustc_middle::middle::{
12 codegen_fn_attrs::CodegenFnAttrFlags, dependency_format::Linkage,
13 exported_symbols::ExportedSymbol,
15 use rustc_middle::mir;
17 use rustc_session::config::CrateType;
18 use rustc_span::{symbol::sym, Symbol};
24 use super::backtrace::EvalContextExt as _;
27 /// Returned by `emulate_foreign_item_by_name`.
28 pub enum EmulateByNameResult<'mir, 'tcx> {
29 /// The caller is expected to jump to the return block.
31 /// Jumping has already been taken care of.
33 /// A MIR body has been found for the function
34 MirBody(&'mir mir::Body<'tcx>, ty::Instance<'tcx>),
35 /// The item is not supported.
39 impl<'mir, 'tcx: 'mir> EvalContextExt<'mir, 'tcx> for crate::MiriEvalContext<'mir, 'tcx> {}
40 pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriEvalContextExt<'mir, 'tcx> {
41 /// Returns the minimum alignment for the target architecture for allocations of the given size.
42 fn min_align(&self, size: u64, kind: MiriMemoryKind) -> Align {
43 let this = self.eval_context_ref();
44 // List taken from `libstd/sys_common/alloc.rs`.
45 let min_align = match this.tcx.sess.target.arch.as_ref() {
46 "x86" | "arm" | "mips" | "powerpc" | "powerpc64" | "asmjs" | "wasm32" => 8,
47 "x86_64" | "aarch64" | "mips64" | "s390x" | "sparc64" => 16,
48 arch => bug!("Unsupported target architecture: {}", arch),
50 // Windows always aligns, even small allocations.
51 // Source: <https://support.microsoft.com/en-us/help/286470/how-to-use-pageheap-exe-in-windows-xp-windows-2000-and-windows-server>
52 // But jemalloc does not, so for the C heap we only align if the allocation is sufficiently big.
53 if kind == MiriMemoryKind::WinHeap || size >= min_align {
54 return Align::from_bytes(min_align).unwrap();
56 // We have `size < min_align`. Round `size` *down* to the next power of two and use that.
57 fn prev_power_of_two(x: u64) -> u64 {
58 let next_pow2 = x.next_power_of_two();
60 // x *is* a power of two, just use that.
63 // x is between two powers, so next = 2*prev.
67 Align::from_bytes(prev_power_of_two(size)).unwrap()
75 ) -> InterpResult<'tcx, Pointer<Option<Tag>>> {
76 let this = self.eval_context_mut();
80 let align = this.min_align(size, kind);
81 let ptr = this.allocate_ptr(Size::from_bytes(size), align, kind.into())?;
83 // We just allocated this, the access is definitely in-bounds.
84 this.write_bytes_ptr(ptr.into(), iter::repeat(0u8).take(size as usize)).unwrap();
90 fn free(&mut self, ptr: Pointer<Option<Tag>>, kind: MiriMemoryKind) -> InterpResult<'tcx> {
91 let this = self.eval_context_mut();
92 if !this.ptr_is_null(ptr)? {
93 this.deallocate_ptr(ptr, None, kind.into())?;
100 old_ptr: Pointer<Option<Tag>>,
102 kind: MiriMemoryKind,
103 ) -> InterpResult<'tcx, Pointer<Option<Tag>>> {
104 let this = self.eval_context_mut();
105 let new_align = this.min_align(new_size, kind);
106 if this.ptr_is_null(old_ptr)? {
111 this.allocate_ptr(Size::from_bytes(new_size), new_align, kind.into())?;
116 this.deallocate_ptr(old_ptr, None, kind.into())?;
119 let new_ptr = this.reallocate_ptr(
122 Size::from_bytes(new_size),
131 /// Lookup the body of a function that has `link_name` as the symbol name.
132 fn lookup_exported_symbol(
135 ) -> InterpResult<'tcx, Option<(&'mir mir::Body<'tcx>, ty::Instance<'tcx>)>> {
136 let this = self.eval_context_mut();
137 let tcx = this.tcx.tcx;
139 // If the result was cached, just return it.
140 // (Cannot use `or_insert` since the code below might have to throw an error.)
141 let entry = this.machine.exported_symbols_cache.entry(link_name);
142 let instance = *match entry {
143 Entry::Occupied(e) => e.into_mut(),
144 Entry::Vacant(e) => {
145 // Find it if it was not cached.
146 let mut instance_and_crate: Option<(ty::Instance<'_>, CrateNum)> = None;
147 // `dependency_formats` includes all the transitive informations needed to link a crate,
148 // which is what we need here since we need to dig out `exported_symbols` from all transitive
150 let dependency_formats = tcx.dependency_formats(());
151 let dependency_format = dependency_formats
153 .find(|(crate_type, _)| *crate_type == CrateType::Executable)
154 .expect("interpreting a non-executable crate");
155 for cnum in iter::once(LOCAL_CRATE).chain(
156 dependency_format.1.iter().enumerate().filter_map(|(num, &linkage)| {
157 (linkage != Linkage::NotLinked).then_some(CrateNum::new(num + 1))
160 // We can ignore `_export_info` here: we are a Rust crate, and everything is exported
161 // from a Rust crate.
162 for &(symbol, _export_info) in tcx.exported_symbols(cnum) {
163 if let ExportedSymbol::NonGeneric(def_id) = symbol {
164 let attrs = tcx.codegen_fn_attrs(def_id);
165 let symbol_name = if let Some(export_name) = attrs.export_name {
167 } else if attrs.flags.contains(CodegenFnAttrFlags::NO_MANGLE) {
168 tcx.item_name(def_id)
170 // Skip over items without an explicitly defined symbol name.
173 if symbol_name == link_name {
174 if let Some((original_instance, original_cnum)) = instance_and_crate
176 // Make sure we are consistent wrt what is 'first' and 'second'.
178 tcx.def_span(original_instance.def_id()).data();
179 let span = tcx.def_span(def_id).data();
180 if original_span < span {
182 TerminationInfo::MultipleSymbolDefinitions {
184 first: original_span,
185 first_crate: tcx.crate_name(original_cnum),
187 second_crate: tcx.crate_name(cnum),
192 TerminationInfo::MultipleSymbolDefinitions {
195 first_crate: tcx.crate_name(cnum),
196 second: original_span,
197 second_crate: tcx.crate_name(original_cnum),
202 if !matches!(tcx.def_kind(def_id), DefKind::Fn | DefKind::AssocFn) {
204 "attempt to call an exported symbol that is not defined as a function"
207 instance_and_crate = Some((ty::Instance::mono(tcx, def_id), cnum));
213 e.insert(instance_and_crate.map(|ic| ic.0))
217 None => Ok(None), // no symbol with this name
218 Some(instance) => Ok(Some((this.load_mir(instance.def, None)?, instance))),
222 /// Emulates calling a foreign item, failing if the item is not supported.
223 /// This function will handle `goto_block` if needed.
224 /// Returns Ok(None) if the foreign item was completely handled
225 /// by this function.
226 /// Returns Ok(Some(body)) if processing the foreign item
227 /// is delegated to another function.
228 fn emulate_foreign_item(
232 args: &[OpTy<'tcx, Tag>],
233 ret: Option<(&PlaceTy<'tcx, Tag>, mir::BasicBlock)>,
234 unwind: StackPopUnwind,
235 ) -> InterpResult<'tcx, Option<(&'mir mir::Body<'tcx>, ty::Instance<'tcx>)>> {
236 let this = self.eval_context_mut();
237 let attrs = this.tcx.get_attrs(def_id);
241 .first_attr_value_str_by_name(&attrs, sym::link_name)
242 .unwrap_or_else(|| this.tcx.item_name(def_id));
243 let tcx = this.tcx.tcx;
245 // First: functions that diverge.
246 let (dest, ret) = match ret {
248 match &*link_name.as_str() {
249 "miri_start_panic" => {
250 // `check_shim` happens inside `handle_miri_start_panic`.
251 this.handle_miri_start_panic(abi, link_name, args, unwind)?;
254 // This matches calls to the foreign item `panic_impl`.
255 // The implementation is provided by the function with the `#[panic_handler]` attribute.
257 // We don't use `check_shim` here because we are just forwarding to the lang
258 // item. Argument count checking will be performed when the returned `Body` is
260 this.check_abi_and_shim_symbol_clash(abi, Abi::Rust, link_name)?;
261 let panic_impl_id = tcx.lang_items().panic_impl().unwrap();
262 let panic_impl_instance = ty::Instance::mono(tcx, panic_impl_id);
264 &*this.load_mir(panic_impl_instance.def, None)?,
272 let exp_abi = if link_name.as_str() == "exit" {
273 Abi::C { unwind: false }
275 Abi::System { unwind: false }
277 let &[ref code] = this.check_shim(abi, exp_abi, link_name, args)?;
278 // it's really u32 for ExitProcess, but we have to put it into the `Exit` variant anyway
279 let code = this.read_scalar(code)?.to_i32()?;
280 throw_machine_stop!(TerminationInfo::Exit(code.into()));
284 this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
285 throw_machine_stop!(TerminationInfo::Abort(
286 "the program aborted execution".to_owned()
290 if let Some(body) = this.lookup_exported_symbol(link_name)? {
291 return Ok(Some(body));
293 this.handle_unsupported(format!(
294 "can't call (diverging) foreign function: {}",
303 // Second: functions that return.
304 match this.emulate_foreign_item_by_name(link_name, abi, args, dest, ret)? {
305 EmulateByNameResult::NeedsJumping => {
306 trace!("{:?}", this.dump_place(**dest));
307 this.go_to_block(ret);
309 EmulateByNameResult::AlreadyJumped => (),
310 EmulateByNameResult::MirBody(mir, instance) => return Ok(Some((mir, instance))),
311 EmulateByNameResult::NotSupported => {
312 if let Some(body) = this.lookup_exported_symbol(link_name)? {
313 return Ok(Some(body));
316 this.handle_unsupported(format!("can't call foreign function: {}", link_name))?;
324 /// Emulates calling the internal __rust_* allocator functions
325 fn emulate_allocator(
328 default: impl FnOnce(&mut MiriEvalContext<'mir, 'tcx>) -> InterpResult<'tcx>,
329 ) -> InterpResult<'tcx, EmulateByNameResult<'mir, 'tcx>> {
330 let this = self.eval_context_mut();
332 let allocator_kind = if let Some(allocator_kind) = this.tcx.allocator_kind(()) {
335 // in real code, this symbol does not exist without an allocator
336 return Ok(EmulateByNameResult::NotSupported);
339 match allocator_kind {
340 AllocatorKind::Global => {
341 let (body, instance) = this
342 .lookup_exported_symbol(symbol)?
343 .expect("symbol should be present if there is a global allocator");
345 Ok(EmulateByNameResult::MirBody(body, instance))
347 AllocatorKind::Default => {
349 Ok(EmulateByNameResult::NeedsJumping)
354 /// Emulates calling a foreign item using its name.
355 fn emulate_foreign_item_by_name(
359 args: &[OpTy<'tcx, Tag>],
360 dest: &PlaceTy<'tcx, Tag>,
361 ret: mir::BasicBlock,
362 ) -> InterpResult<'tcx, EmulateByNameResult<'mir, 'tcx>> {
363 let this = self.eval_context_mut();
365 // Here we dispatch all the shims for foreign functions. If you have a platform specific
366 // shim, add it to the corresponding submodule.
367 match &*link_name.as_str() {
368 // Miri-specific extern functions
369 "miri_static_root" => {
370 let &[ref ptr] = this.check_shim(abi, Abi::Rust, link_name, args)?;
371 let ptr = this.read_pointer(ptr)?;
372 let (alloc_id, offset, _) = this.ptr_get_alloc_id(ptr)?;
373 if offset != Size::ZERO {
374 throw_unsup_format!("pointer passed to miri_static_root must point to beginning of an allocated block");
376 this.machine.static_roots.push(alloc_id);
379 // Obtains the size of a Miri backtrace. See the README for details.
380 "miri_backtrace_size" => {
381 this.handle_miri_backtrace_size(abi, link_name, args, dest)?;
384 // Obtains a Miri backtrace. See the README for details.
385 "miri_get_backtrace" => {
386 // `check_shim` happens inside `handle_miri_get_backtrace`.
387 this.handle_miri_get_backtrace(abi, link_name, args, dest)?;
390 // Resolves a Miri backtrace frame. See the README for details.
391 "miri_resolve_frame" => {
392 // `check_shim` happens inside `handle_miri_resolve_frame`.
393 this.handle_miri_resolve_frame(abi, link_name, args, dest)?;
396 // Writes the function and file names of a Miri backtrace frame into a user provided buffer. See the README for details.
397 "miri_resolve_frame_names" => {
398 this.handle_miri_resolve_frame_names(abi, link_name, args)?;
401 // Standard C allocation
403 let &[ref size] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
404 let size = this.read_scalar(size)?.to_machine_usize(this)?;
405 let res = this.malloc(size, /*zero_init:*/ false, MiriMemoryKind::C)?;
406 this.write_pointer(res, dest)?;
409 let &[ref items, ref len] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
410 let items = this.read_scalar(items)?.to_machine_usize(this)?;
411 let len = this.read_scalar(len)?.to_machine_usize(this)?;
413 items.checked_mul(len).ok_or_else(|| err_ub_format!("overflow during calloc size computation"))?;
414 let res = this.malloc(size, /*zero_init:*/ true, MiriMemoryKind::C)?;
415 this.write_pointer(res, dest)?;
418 let &[ref ptr] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
419 let ptr = this.read_pointer(ptr)?;
420 this.free(ptr, MiriMemoryKind::C)?;
423 let &[ref old_ptr, ref new_size] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
424 let old_ptr = this.read_pointer(old_ptr)?;
425 let new_size = this.read_scalar(new_size)?.to_machine_usize(this)?;
426 let res = this.realloc(old_ptr, new_size, MiriMemoryKind::C)?;
427 this.write_pointer(res, dest)?;
432 let &[ref size, ref align] = this.check_shim(abi, Abi::Rust, link_name, args)?;
433 let size = this.read_scalar(size)?.to_machine_usize(this)?;
434 let align = this.read_scalar(align)?.to_machine_usize(this)?;
436 return this.emulate_allocator(Symbol::intern("__rg_alloc"), |this| {
437 Self::check_alloc_request(size, align)?;
439 let ptr = this.allocate_ptr(
440 Size::from_bytes(size),
441 Align::from_bytes(align).unwrap(),
442 MiriMemoryKind::Rust.into(),
445 this.write_pointer(ptr, dest)
448 "__rust_alloc_zeroed" => {
449 let &[ref size, ref align] = this.check_shim(abi, Abi::Rust, link_name, args)?;
450 let size = this.read_scalar(size)?.to_machine_usize(this)?;
451 let align = this.read_scalar(align)?.to_machine_usize(this)?;
453 return this.emulate_allocator(Symbol::intern("__rg_alloc_zeroed"), |this| {
454 Self::check_alloc_request(size, align)?;
456 let ptr = this.allocate_ptr(
457 Size::from_bytes(size),
458 Align::from_bytes(align).unwrap(),
459 MiriMemoryKind::Rust.into(),
462 // We just allocated this, the access is definitely in-bounds.
463 this.write_bytes_ptr(ptr.into(), iter::repeat(0u8).take(usize::try_from(size).unwrap())).unwrap();
464 this.write_pointer(ptr, dest)
467 "__rust_dealloc" => {
468 let &[ref ptr, ref old_size, ref align] = this.check_shim(abi, Abi::Rust, link_name, args)?;
469 let ptr = this.read_pointer(ptr)?;
470 let old_size = this.read_scalar(old_size)?.to_machine_usize(this)?;
471 let align = this.read_scalar(align)?.to_machine_usize(this)?;
473 return this.emulate_allocator(Symbol::intern("__rg_dealloc"), |this| {
474 // No need to check old_size/align; we anyway check that they match the allocation.
477 Some((Size::from_bytes(old_size), Align::from_bytes(align).unwrap())),
478 MiriMemoryKind::Rust.into(),
482 "__rust_realloc" => {
483 let &[ref ptr, ref old_size, ref align, ref new_size] = this.check_shim(abi, Abi::Rust, link_name, args)?;
484 let ptr = this.read_pointer(ptr)?;
485 let old_size = this.read_scalar(old_size)?.to_machine_usize(this)?;
486 let align = this.read_scalar(align)?.to_machine_usize(this)?;
487 let new_size = this.read_scalar(new_size)?.to_machine_usize(this)?;
488 // No need to check old_size; we anyway check that they match the allocation.
490 return this.emulate_allocator(Symbol::intern("__rg_realloc"), |this| {
491 Self::check_alloc_request(new_size, align)?;
493 let align = Align::from_bytes(align).unwrap();
494 let new_ptr = this.reallocate_ptr(
496 Some((Size::from_bytes(old_size), align)),
497 Size::from_bytes(new_size),
499 MiriMemoryKind::Rust.into(),
501 this.write_pointer(new_ptr, dest)
505 // C memory handling functions
507 let &[ref left, ref right, ref n] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
508 let left = this.read_pointer(left)?;
509 let right = this.read_pointer(right)?;
510 let n = Size::from_bytes(this.read_scalar(n)?.to_machine_usize(this)?);
513 let left_bytes = this.read_bytes_ptr(left, n)?;
514 let right_bytes = this.read_bytes_ptr(right, n)?;
516 use std::cmp::Ordering::*;
517 match left_bytes.cmp(right_bytes) {
524 this.write_scalar(Scalar::from_i32(result), dest)?;
527 let &[ref ptr, ref val, ref num] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
528 let ptr = this.read_pointer(ptr)?;
529 let val = this.read_scalar(val)?.to_i32()? as u8;
530 let num = this.read_scalar(num)?.to_machine_usize(this)?;
531 if let Some(idx) = this
532 .read_bytes_ptr(ptr, Size::from_bytes(num))?
535 .position(|&c| c == val)
537 let new_ptr = ptr.offset(Size::from_bytes(num - idx as u64 - 1), this)?;
538 this.write_pointer(new_ptr, dest)?;
540 this.write_null(dest)?;
544 let &[ref ptr, ref val, ref num] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
545 let ptr = this.read_pointer(ptr)?;
546 let val = this.read_scalar(val)?.to_i32()? as u8;
547 let num = this.read_scalar(num)?.to_machine_usize(this)?;
549 .read_bytes_ptr(ptr, Size::from_bytes(num))?
551 .position(|&c| c == val);
552 if let Some(idx) = idx {
553 let new_ptr = ptr.offset(Size::from_bytes(idx as u64), this)?;
554 this.write_pointer(new_ptr, dest)?;
556 this.write_null(dest)?;
560 let &[ref ptr] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
561 let ptr = this.read_pointer(ptr)?;
562 let n = this.read_c_str(ptr)?.len();
563 this.write_scalar(Scalar::from_machine_usize(u64::try_from(n).unwrap(), this), dest)?;
576 let &[ref f] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
577 // FIXME: Using host floats.
578 let f = f32::from_bits(this.read_scalar(f)?.to_u32()?);
579 let f = match &*link_name.as_str() {
589 this.write_scalar(Scalar::from_u32(f.to_bits()), dest)?;
596 let &[ref f1, ref f2] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
597 // underscore case for windows, here and below
598 // (see https://docs.microsoft.com/en-us/cpp/c-runtime-library/reference/floating-point-primitives?view=vs-2019)
599 // FIXME: Using host floats.
600 let f1 = f32::from_bits(this.read_scalar(f1)?.to_u32()?);
601 let f2 = f32::from_bits(this.read_scalar(f2)?.to_u32()?);
602 let n = match &*link_name.as_str() {
603 "_hypotf" | "hypotf" => f1.hypot(f2),
604 "atan2f" => f1.atan2(f2),
607 this.write_scalar(Scalar::from_u32(n.to_bits()), dest)?;
618 let &[ref f] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
619 // FIXME: Using host floats.
620 let f = f64::from_bits(this.read_scalar(f)?.to_u64()?);
621 let f = match &*link_name.as_str() {
631 this.write_scalar(Scalar::from_u64(f.to_bits()), dest)?;
638 let &[ref f1, ref f2] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
639 // FIXME: Using host floats.
640 let f1 = f64::from_bits(this.read_scalar(f1)?.to_u64()?);
641 let f2 = f64::from_bits(this.read_scalar(f2)?.to_u64()?);
642 let n = match &*link_name.as_str() {
643 "_hypot" | "hypot" => f1.hypot(f2),
644 "atan2" => f1.atan2(f2),
647 this.write_scalar(Scalar::from_u64(n.to_bits()), dest)?;
654 let &[ref x, ref exp] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
655 // For radix-2 (binary) systems, `ldexp` and `scalbn` are the same.
656 let x = this.read_scalar(x)?.to_f64()?;
657 let exp = this.read_scalar(exp)?.to_i32()?;
659 // Saturating cast to i16. Even those are outside the valid exponent range to
660 // `scalbn` below will do its over/underflow handling.
661 let exp = if exp > i32::from(i16::MAX) {
663 } else if exp < i32::from(i16::MIN) {
666 exp.try_into().unwrap()
669 let res = x.scalbn(exp);
670 this.write_scalar(Scalar::from_f64(res), dest)?;
673 // Architecture-specific shims
674 "llvm.x86.addcarry.64" if this.tcx.sess.target.arch == "x86_64" => {
675 // Computes u8+u64+u64, returning tuple (u8,u64) comprising the output carry and truncated sum.
676 let &[ref c_in, ref a, ref b] = this.check_shim(abi, Abi::Unadjusted, link_name, args)?;
677 let c_in = this.read_scalar(c_in)?.to_u8()?;
678 let a = this.read_scalar(a)?.to_u64()?;
679 let b = this.read_scalar(b)?.to_u64()?;
681 let wide_sum = c_in as u128 + a as u128 + b as u128;
682 let (c_out, sum) = ((wide_sum >> 64) as u8, wide_sum as u64);
684 let c_out_field = this.place_field(dest, 0)?;
685 this.write_scalar(Scalar::from_u8(c_out), &c_out_field)?;
686 let sum_field = this.place_field(dest, 1)?;
687 this.write_scalar(Scalar::from_u64(sum), &sum_field)?;
689 "llvm.x86.sse2.pause" if this.tcx.sess.target.arch == "x86" || this.tcx.sess.target.arch == "x86_64" => {
690 let &[] = this.check_shim(abi, Abi::C { unwind: false }, link_name, args)?;
691 this.yield_active_thread();
693 "llvm.aarch64.isb" if this.tcx.sess.target.arch == "aarch64" => {
694 let &[ref arg] = this.check_shim(abi, Abi::Unadjusted, link_name, args)?;
695 let arg = this.read_scalar(arg)?.to_i32()?;
697 15 => { // SY ("full system scope")
698 this.yield_active_thread();
701 throw_unsup_format!("unsupported llvm.aarch64.isb argument {}", arg);
706 // Platform-specific shims
707 _ => match this.tcx.sess.target.os.as_ref() {
708 "linux" | "macos" => return shims::posix::foreign_items::EvalContextExt::emulate_foreign_item_by_name(this, link_name, abi, args, dest, ret),
709 "windows" => return shims::windows::foreign_items::EvalContextExt::emulate_foreign_item_by_name(this, link_name, abi, args, dest, ret),
710 target => throw_unsup_format!("the target `{}` is not supported", target),
714 // We only fall through to here if we did *not* hit the `_` arm above,
715 // i.e., if we actually emulated the function.
716 Ok(EmulateByNameResult::NeedsJumping)
719 /// Check some basic requirements for this allocation request:
720 /// non-zero size, power-of-two alignment.
721 fn check_alloc_request(size: u64, align: u64) -> InterpResult<'tcx> {
723 throw_ub_format!("creating allocation with size 0");
725 if !align.is_power_of_two() {
726 throw_ub_format!("creating allocation with non-power-of-two alignment {}", align);