Skip to content

analyze: run equiv pass before pointee #1173

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

Merged
merged 11 commits into from
Dec 3, 2024

Conversation

spernsteiner
Copy link
Collaborator

This branch changes the order of analysis passes to run the equivalence class analysis and PointerId renumbering before running the pointee type analysis. In particular, this improves the pointee results in cases involving fresh references, such as this new test case:

let mut p = 0 as *mut libc::c_void;
let fresh = &mut p;
*fresh = malloc(4);

Most of the changes here are refactorings to move specific analysis passes from run() into helper functions, which makes them easier to reorder.

@spernsteiner spernsteiner requested a review from ahomescu December 2, 2024 18:39
fn pointee_type(&self, ptr: PointerId) -> Option<LTy<'tcx>> {
self.pointee_types
.as_ref()
.and_then(|pointee_types| pointee_types[ptr].get_sole_lty())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will this panic if ptr is out of bounds?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It will panic if ptr is PointerId::NONE (the same is true of the code this is replacing). I added an assert just to make it clear that this should only be called on actual pointers: 7f1d501

@spernsteiner spernsteiner force-pushed the analyze-equiv-before-pointee-base branch from 74a6d31 to 955f20b Compare December 3, 2024 17:41
@spernsteiner spernsteiner force-pushed the analyze-equiv-before-pointee branch from d4efb1a to 7f1d501 Compare December 3, 2024 17:41
@spernsteiner spernsteiner force-pushed the analyze-equiv-before-pointee-base branch from 955f20b to a0850b1 Compare December 3, 2024 18:54
@spernsteiner spernsteiner force-pushed the analyze-equiv-before-pointee branch from 7f1d501 to e1c17c4 Compare December 3, 2024 18:54
@spernsteiner spernsteiner changed the base branch from analyze-equiv-before-pointee-base to master December 3, 2024 18:54
@spernsteiner spernsteiner force-pushed the analyze-equiv-before-pointee branch from e1c17c4 to 7013b6d Compare December 3, 2024 18:54
@spernsteiner spernsteiner merged commit ecd1cbc into master Dec 3, 2024
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants