-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[NLL] convert NLL Region representation into a bit set #45670
Copy link
Copy link
Closed
Labels
E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.Call for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
The present set of NLL patches uses a terribly inefficient representation for regions consisting of two btrees. I think what we probably want is to use a
librustc_data_structures::bitvec::BitMatrix, which is a 2D matrix where each cell can be a boolean. The "rows" here would be the region indices and the "columns" would be the locations + free regions.As of #45668, the representation of
Regionis encapsulated within theregion_context.rsmodule, so this change should be fairly easy to make. The basic idea would be that, when we initialize theRegionInferenceContext, we have on hand everything we need to allocate theBitMatrix-- that is, we know how many rows and columns we will need.So the basic steps would be:
Locationto its column index.init_free_regions; it is basically a loop over the basic blocks and then the locations within each basic block.valuefield fromRegionDefinitionBitMatrixstored as a field in theRegionInferenceContextvaluefield likeregion_contains_point, this should be largely straightforwardBitMatrixalready supports some APIs for that, we may want to add a few more or just tweak howDFSworks