Skip to content

Commit b0986e9

Browse files
committed
Use may_have_provenance.
1 parent 4712cc3 commit b0986e9

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
@@ -1844,25 +1844,7 @@ fn op_to_prop_const<'tcx>(
18441844
// Everything failed: create a new allocation to hold the data.
18451845
let alloc_id =
18461846
ecx.intern_with_temp_alloc(op.layout, |ecx, dest| ecx.copy_op(op, dest)).discard_err()?;
1847-
let value = ConstValue::Indirect { alloc_id, offset: Size::ZERO };
1848-
1849-
// Check that we do not leak a pointer.
1850-
// Those pointers may lose part of their identity in codegen.
1851-
// FIXME: remove this hack once https://github.com/rust-lang/rust/issues/128775 is fixed.
1852-
if ecx
1853-
.tcx
1854-
.global_alloc(alloc_id)
1855-
.unwrap_memory()
1856-
.inner()
1857-
.provenance()
1858-
.provenances()
1859-
.next()
1860-
.is_none()
1861-
{
1862-
return Some(value);
1863-
}
1864-
1865-
None
1847+
Some(ConstValue::Indirect { alloc_id, offset: Size::ZERO })
18661848
}
18671849

18681850
impl<'tcx> VnState<'_, '_, 'tcx> {
@@ -1916,7 +1898,9 @@ impl<'tcx> VnState<'_, '_, 'tcx> {
19161898
// Check that we do not leak a pointer.
19171899
// Those pointers may lose part of their identity in codegen.
19181900
// FIXME: remove this hack once https://github.com/rust-lang/rust/issues/128775 is fixed.
1919-
assert!(!may_have_provenance(self.tcx, value, op.layout.size));
1901+
if may_have_provenance(self.tcx, value, op.layout.size) {
1902+
return None;
1903+
}
19201904

19211905
Some(Const::Val(value, op.layout.ty))
19221906
}

0 commit comments

Comments
 (0)