Skip to content
This repository was archived by the owner on Jun 20, 2019. It is now read-only.

Commit 9891aaa

Browse files
committed
Mark _d_allocmemory as ECF_PURE.
1 parent bb5ea63 commit 9891aaa

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

gcc/d/ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2018-02-11 Iain Buclaw <[email protected]>
2+
3+
* d-codegen.cc (d_save_expr): Always stabilize CALL_EXPR.
4+
* runtime.def (ALLOCMEMORY): Set ECF_PURE.
5+
16
2018-02-11 Iain Buclaw <[email protected]>
27

38
* runtime.def (ASSERT, ASSERT_MSG): Set ECF_COLD and ECF_LEAF flags.

gcc/d/d-codegen.cc

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,9 +506,14 @@ lvalue_p (tree exp)
506506
tree
507507
d_save_expr (tree exp)
508508
{
509-
if (TREE_SIDE_EFFECTS (exp))
509+
/* Always consider call expressions as a side effect, even if the function
510+
being called is pure. */
511+
tree t = exp;
512+
STRIP_NOPS (t);
513+
514+
if (TREE_SIDE_EFFECTS (t) || TREE_CODE (t) == CALL_EXPR)
510515
{
511-
if (lvalue_p (exp))
516+
if (lvalue_p (t))
512517
return stabilize_reference (exp);
513518

514519
return save_expr (exp);

gcc/d/runtime.def

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,7 @@ DEF_D_RUNTIME (ARRAYSETLENGTHIT, "_d_arraysetlengthiT", RT(ARRAY_VOID),
118118

119119
/* Used for allocating closures on the GC heap. */
120120
DEF_D_RUNTIME (ALLOCMEMORY, "_d_allocmemory", RT(VOIDPTR), P1(SIZE_T),
121-
ECF_MALLOC)
121+
ECF_MALLOC | ECF_PURE)
122122

123123
/* Used for copying an array into a slice, adds an enforcment that the source
124124
and destination are equal in size and do not overlap. */

0 commit comments

Comments
 (0)