Bug creation and email sending has been disabled, file new bugs at gcc.gnu.org/bugzilla
Bug 228 - Creation of temporaries internally needs to be taken back under control.
Summary: Creation of temporaries internally needs to be taken back under control.
Status: RESOLVED FIXED
Alias: None
Product: GDC
Classification: Unclassified
Component: gdc (show other bugs)
Version: development
Hardware: All All
: --- normal
Assignee: Iain Buclaw
URL:
Depends on:
Blocks:
 
Reported: 2016-06-06 07:28 CEST by Iain Buclaw
Modified: 2016-06-20 09:52 CEST (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Iain Buclaw 2016-06-06 07:28:45 CEST
See, for instance: https://github.com/D-Programming-GDC/GDC/pull/217

Though the use of COMPOUND_EXPR  seems to make the matter look worse, it should be investigated why we create so many temporaries (SAVE_EXPRs).

Having a single pass after generating the code is not ideal.  If it is indeed simply COMPOUND_EXPRs with side effects, then we should make all codegen helpers COMPOUND_EXPR-aware.

e.g:

  build_deref(build_nop(type, build_address(expr)));

Should not result in:

  *((TYPE *)&(foo(), bar));

Instead always apply the action to the right-most result.

  (foo(), *(TYPE *)&bar);

This should simplify inspecting expressions in order-sensitive parts, where the question "Do we need a temporary?" in maybe_make_temp could three possible answers - Yes; No; and No, but the left hand side (normally construction) needs to be executed first.

Creating temporaries at every step also blocks bug42.
Comment 1 Iain Buclaw 2016-06-10 17:40:08 CEST
https://github.com/D-Programming-GDC/GDC/pull/219
Comment 2 Iain Buclaw 2016-06-20 09:52:02 CEST
https://github.com/D-Programming-GDC/GDC/pull/221
https://github.com/D-Programming-GDC/GDC/pull/224
https://github.com/D-Programming-GDC/GDC/pull/225

Marking this as done as it's "good enough" for now to allow bug42 to be fixed.