This is an archive of the discontinued LLVM Phabricator instance.

Update basic deref API to account for possiblity of free [NFC]
ClosedPublic

Authored by reames on Mar 18 2021, 5:13 PM.

Details

Summary

This patch is plumbing to support work towards the goal outlined in the recent llvm-dev post "[llvm-dev] RFC: Decomposing deref(N) into deref(N) + nofree".

The point of this change is purely to simplify iteration on other pieces on way to making the switch. Rebuilding with a change to Value.h is slow and painful, so I want to get the API change landed. Once that's done, I plan to more closely audit each caller, add the inference rules in their own patch, then post a patch with the langref changes and test diffs. The value of the command line flag is that we can exercise the inference logic in standalone patches without needing the whole switch ready to go just yet.

Diff Detail

Event Timeline

reames created this revision.Mar 18 2021, 5:13 PM
reames requested review of this revision.Mar 18 2021, 5:13 PM
Herald added a reviewer: baziotis. · View Herald Transcript
Herald added a project: Restricted Project. · View Herald Transcript
Herald added a subscriber: bbn. · View Herald Transcript

Sounds good to me, as long as you commit to removing that cmd switch within a reasonable time frame. Otherwise we accumulate technical debt.

This patch just shows how terrible this LLVM thing of traversing things backwards can be. Just because a pointer can be freed, it doesn't mean it was. This patch is quite pessimistic; essentially it assumes all pointers are dead. What's the plan to avoid regressions?

Sounds good to me, as long as you commit to removing that cmd switch within a reasonable time frame. Otherwise we accumulate technical debt.

I do. Just to be clear, your SGTM is meant as an LGTM right?

This patch just shows how terrible this LLVM thing of traversing things backwards can be. Just because a pointer can be freed, it doesn't mean it was. This patch is quite pessimistic; essentially it assumes all pointers are dead. What's the plan to avoid regressions?

This patch is extraordinarily pessimistic. :)

First step is to add a predicate for when we know an object can't be freed in the queried scope. I have an initial version of that implemented, and it does cover a large number of existing cases. After that, I'm going to be looking closely at existing test cases to see what other inference looks profitable. (I've already spotted a couple of additional inference rules which look possible that way.) I want to get each "interesting" inference rule into it's own review for ease of discussion. (Or at least small batches of related inference rules.)

Once all of that is done, I'll post a final review which flips the flag with all the doc changes, and any remaining test changes. If we feel that the remaining delta in optimization potential is too large, we can explore one of the other attribute options mentioned in the RFC thread.

nlopes accepted this revision.Mar 19 2021, 10:06 AM

It is LGTM, yes.
Thanks for the details on the plan. Sounds great, thanks!

This revision is now accepted and ready to land.Mar 19 2021, 10:06 AM
This revision was landed with ongoing or failed builds.Mar 19 2021, 11:17 AM
This revision was automatically updated to reflect the committed changes.