-
-
Notifications
You must be signed in to change notification settings - Fork 607
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
POC: automatically move scope array literals to the stack #16897
base: master
Are you sure you want to change the base?
Conversation
Thanks for your pull request and interest in making D better, @dkorpel! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub run digger -- build "master + dmd#16897" |
I assume you will make |
62bc416
to
22c1a56
Compare
If this is actually worth pursuing, yes. It's non-trivial because currently, |
22c1a56
to
a179c54
Compare
This doesn't work for me, however this does: dmd/compiler/src/dmd/dsymbolsem.d Lines 1331 to 1338 in 6d2f652
else if (auto ale = ex.isArrayLiteralExp())
{
// or an array literal assigned to a `scope` variable
- if (sc.useDIP1000 == FeatureState.enabled
+ if ((sc.useDIP1000 == FeatureState.enabled || global.params.betterC)
&& !dsym.type.nextOf().needsDestruction())
ale.onstack = true;
} |
My patch works with your tests too, please use it instead, more efficient, and let's merge |
That patch could introduce dangling pointers in
|
From what i see, that DIP is 8 years old I'm not gonna rely on a rotten DIP and i don't use attributes new patch: else if (auto ale = ex.isArrayLiteralExp())
{
// or an array literal assigned to a `scope` variable
- if (sc.useDIP1000 == FeatureState.enabled
+ if ((sc.useDIP1000 == FeatureState.enabled || (global.params.betterC && !sc.func.isSafe()))
&& !dsym.type.nextOf().needsDestruction())
ale.onstack = true;
} Let's merge |
See #16888 (comment)
Just a proof of concept, I don't think this is worth merging at this stage. Maybe under
-preview=dip1000
only.