Verify that allocations output by GVN are sufficiently aligned.
This commit is contained in:
parent
6aebb2cfec
commit
b97f83b27f
@ -1391,11 +1391,15 @@ fn op_to_prop_const<'tcx>(
|
||||
let (prov, offset) = pointer.into_parts();
|
||||
let alloc_id = prov.alloc_id();
|
||||
intern_const_alloc_for_constprop(ecx, alloc_id).ok()?;
|
||||
if matches!(ecx.tcx.global_alloc(alloc_id), GlobalAlloc::Memory(_)) {
|
||||
// `alloc_id` may point to a static. Codegen will choke on an `Indirect` with anything
|
||||
// by `GlobalAlloc::Memory`, so do fall through to copying if needed.
|
||||
// FIXME: find a way to treat this more uniformly
|
||||
// (probably by fixing codegen)
|
||||
|
||||
// `alloc_id` may point to a static. Codegen will choke on an `Indirect` with anything
|
||||
// by `GlobalAlloc::Memory`, so do fall through to copying if needed.
|
||||
// FIXME: find a way to treat this more uniformly (probably by fixing codegen)
|
||||
if let GlobalAlloc::Memory(alloc) = ecx.tcx.global_alloc(alloc_id)
|
||||
// Transmuting a constant is just an offset in the allocation. If the alignement of the
|
||||
// allocation is noe enough, fallback to copying into a properly aligned value.
|
||||
&& alloc.inner().align >= op.layout.align.abi
|
||||
{
|
||||
return Some(ConstValue::Indirect { alloc_id, offset });
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user