Skip to content

Commit 04cb159

Browse files
committed
Use may_have_provenance.
1 parent 1a4f7d3 commit 04cb159

1 file changed

Lines changed: 4 additions & 20 deletions

File tree

  • compiler/rustc_mir_transform/src

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 4 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1805,25 +1805,7 @@ fn op_to_prop_const<'tcx>(
18051805
// Everything failed: create a new allocation to hold the data.
18061806
let alloc_id =
18071807
ecx.intern_with_temp_alloc(op.layout, |ecx, dest| ecx.copy_op(op, dest)).discard_err()?;
1808-
let value = ConstValue::Indirect { alloc_id, offset: Size::ZERO };
1809-
1810-
// Check that we do not leak a pointer.
1811-
// Those pointers may lose part of their identity in codegen.
1812-
// FIXME: remove this hack once https://github.com/rust-lang/rust/issues/128775 is fixed.
1813-
if ecx
1814-
.tcx
1815-
.global_alloc(alloc_id)
1816-
.unwrap_memory()
1817-
.inner()
1818-
.provenance()
1819-
.provenances()
1820-
.next()
1821-
.is_none()
1822-
{
1823-
return Some(value);
1824-
}
1825-
1826-
None
1808+
Some(ConstValue::Indirect { alloc_id, offset: Size::ZERO })
18271809
}
18281810

18291811
impl<'tcx> VnState<'_, '_, 'tcx> {
@@ -1877,7 +1859,9 @@ impl<'tcx> VnState<'_, '_, 'tcx> {
18771859
// Check that we do not leak a pointer.
18781860
// Those pointers may lose part of their identity in codegen.
18791861
// FIXME: remove this hack once https://github.com/rust-lang/rust/issues/128775 is fixed.
1880-
assert!(!may_have_provenance(self.tcx, value, op.layout.size));
1862+
if may_have_provenance(self.tcx, value, op.layout.size) {
1863+
return None;
1864+
}
18811865

18821866
Some(Const::Val(value, op.layout.ty))
18831867
}

0 commit comments

Comments
 (0)