Bug 12384 – Improve optimization of nothrow code

Status
NEW
Severity
enhancement
Priority
P4
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-03-16T16:48:55Z
Last change time
2024-12-13T18:18:22Z
Keywords
preapproved
Assigned to
No Owner
Creator
Walter Bright
Moved to GitHub: dmd#18796 →

Comments

Comment #0 by bugzilla — 2014-03-16T16:48:55Z
Consider: ---------------------------- import core.stdc.stdlib; void fun() nothrow; struct B { int* p; size_t x; } size_t fun4(ref B a) { B b; scope (exit) free(b.p); fun(); return b.x + a.x; } ---------------------------- This current sets up an exception handler to call free(b.p), even though no exceptions can be thrown. Instead, the code rewrite should be: --------------------- size_t fun4(ref B a) { B b; fun(); auto tmp = b.x + a.x; free(b.p); return tmp; } ----------------------- This will result in significant performance improvements. Currently, only one such rewrite case is handled in TryFinallyStatement::semantic(). There's more low hanging fruit, such as the return statement case above, that should be handled there. (scope-statements are rewritten as try-finally-statements.)
Comment #1 by bugzilla — 2014-05-04T00:02:09Z
Comment #2 by robert.schadek — 2024-12-13T18:18:22Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18796 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB