Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

See through aggregates in GVN #116270

Merged
merged 28 commits into from
Oct 29, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
d284059
Do not remove unused definitions inside GVN.
cjgillot Sep 16, 2023
afd631c
Do not visit rvalues twice.
cjgillot Sep 23, 2023
38c86b0
Evaluate computed values to constants.
cjgillot Sep 19, 2023
db9bd9b
Do not intern too large aggregates.
cjgillot Sep 23, 2023
9389373
Do not transmute immediates to non-immediates.
cjgillot Sep 23, 2023
692e528
Simplify projections in GVN.
cjgillot Sep 16, 2023
48d2157
Simplify aggregate projections.
cjgillot Sep 16, 2023
f110f22
Simplify repeat expressions.
cjgillot Sep 16, 2023
23d4857
Do not compute actual aggregate type.
cjgillot May 3, 2023
80a5e85
Extract simplify_aggregate.
cjgillot May 21, 2023
dbf9ea3
Transform large arrays into Repeat expressions when possible.
cjgillot Sep 23, 2023
8162dc2
Do not intern GVN temps.
cjgillot Oct 3, 2023
ebc87bf
Directly intern values instead of copying them.
cjgillot Oct 7, 2023
ff6812c
Move provenance checks out of interning method.
cjgillot Oct 10, 2023
fbf0a0c
Explain why we check variant equality.
cjgillot Oct 11, 2023
59235a7
Fortify transmute check.
cjgillot Oct 12, 2023
e3538d1
Do not require absence of metadata.
cjgillot Oct 12, 2023
f08dc9b
Take an AllocId in intern_const_alloc_for_constprop.
cjgillot Oct 12, 2023
5e78b9c
Disambiguate non-deterministic constants.
cjgillot Oct 14, 2023
f6aa3ee
Complete comments.
cjgillot Oct 14, 2023
50559ce
Valtrees for primitive types are fine.
cjgillot Oct 14, 2023
ac0228d
FileCheck gvn.
cjgillot Oct 16, 2023
c4cc9ca
Do not merge fn pointer casts.
cjgillot Oct 21, 2023
d80eb3a
Verify that the alloc_id is Memory.
cjgillot Oct 22, 2023
eda1928
Typo.
cjgillot Oct 23, 2023
72f0e0e
Rename has_provance and tweaks comments.
cjgillot Oct 23, 2023
8561618
Directly check provenance from the AllocId.
cjgillot Oct 23, 2023
24be433
Apply suggestions from code review
cjgillot Oct 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Take an AllocId in intern_const_alloc_for_constprop.
  • Loading branch information
cjgillot committed Oct 25, 2023
commit f08dc9be17aff80e248d37a768faa6cc8738d371
3 changes: 1 addition & 2 deletions compiler/rustc_const_eval/src/interpret/intern.rs
Original file line number Diff line number Diff line change
Expand Up @@ -459,10 +459,9 @@ pub fn intern_const_alloc_for_constprop<
M: CompileTimeMachine<'mir, 'tcx, T>,
>(
ecx: &mut InterpCx<'mir, 'tcx, M>,
ret: &MPlaceTy<'tcx>,
alloc_id: AllocId,
) -> InterpResult<'tcx, ()> {
// Move allocation to `tcx`.
let alloc_id = ret.ptr().provenance.unwrap();
let Some((_, mut alloc)) = ecx.memory.alloc_map.remove(&alloc_id) else {
// Pointer not found in local memory map. It is either a pointer to the global
// map, or dangling.
Expand Down
9 changes: 2 additions & 7 deletions compiler/rustc_mir_transform/src/gvn.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ use rustc_hir::def::DefKind;
use rustc_index::bit_set::BitSet;
use rustc_index::IndexVec;
use rustc_macros::newtype_index;
use rustc_middle::mir::interpret::GlobalAlloc;
use rustc_middle::mir::visit::*;
use rustc_middle::mir::*;
use rustc_middle::ty::layout::LayoutOf;
Expand Down Expand Up @@ -861,14 +860,10 @@ fn op_to_prop_const<'tcx>(
return None;
}

intern_const_alloc_for_constprop(ecx, &mplace).ok()?;
let pointer = mplace.ptr().into_pointer_or_addr().ok()?;
let (alloc_id, offset) = pointer.into_parts();
match ecx.tcx.global_alloc(alloc_id) {
GlobalAlloc::Memory(_) => return Some(ConstValue::Indirect { alloc_id, offset }),
// Fallthrough to copying the data.
_ => {}
}
intern_const_alloc_for_constprop(ecx, alloc_id).ok()?;
return Some(ConstValue::Indirect { alloc_id, offset });
}

// Everything failed: create a new allocation to hold the data.
Expand Down