Restored array_to_subslice3 & code quality optimizations following the DST PR #313
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
According to #312 , I first tried to restore this optimization using
array_to_subslice3. I think the result is ok but what's happening here feels strange for me.At this phase (
PreCleanup3), we are rewritingarray_to_subsliceusingRangeinto aarray_to_subslice3using 2size_ts , but the difference here is that we have the monomorphized definition ofEurydice_array_to_subslice_XX. We have to remove it after this optimization. So basically we define the functionarray_to_subsliceusing abstract syntax withDst_Ref, and replace it later with a C macro by passing the monomorphized return typeDst_Ref_XX.Back to the quality issue, it seems to me that the point is to get rid of the
Rangetype. If so, maybe a better solution is to rewrite them earlier before the monomorphization, therefore we can get a monomorphized func def ofarray_to_subslice3_XXusingsize_ts instead of C macro definition?For the general optimization point, I agree that we could have many improvements. Following the discussion above, I think the question is to choose from:
I'm not sure which one is better, my previous plan is based on 1. Actually the current version is a mixup of 1 and 2 cuz I only wrote the abstract syntax for the functions could not be defined using macro. The
array_to_subslice3issue implies that it is possible to switch from 1 back to 2 for these functions. @protzEdit: I just found that the current macro definition causes stack smashing in
test-libcruxand I don't know why. This is a reason I personally prefer 1 than 2 because C macro is more error-prone.