-
Notifications
You must be signed in to change notification settings - Fork 48
Set more call attributes and fnspec on all library functions. #617
base: master
Are you sure you want to change the base?
Conversation
14d376d
to
9c67c18
Compare
…r user implemented functions as ECF_LEAF.
93ae3e1
to
d0982a7
Compare
Removed the "returns" flag for runtime functions that return an array. Ran into a backend bug that generated wrong codegen. The rest should be fine. |
Made the following amendments:
|
|
What's the rationale to implement this? Do you expect large performance / optimization benefits using the attributes? And it seems NRVO is a never-ending story... |
Currently there is a special case in the middle end that recognises certain malloc-like builtins and removes them if the LHS is eliminated by the DCE. Whereas what would be more desirable is for that to be a call return flag to handle generically.
I.e:
The optimizer can infer that the assert can never be false. This sort of implication however may not be without its downsides, so may need a little more scrutiny over the initial values that I set.
|
Let me be clear that the value of |
LGTM. |
Rationale for call attributes.
ECF_COLD
: On functions that should never be called (_d_assert
,_d_switch_error
, etc...)ECF_LEAF
: On functions that don't callpostblit()
ordestroy()
(_d_allocmemory
, etc...)ECF_NOTHROW
: On functions that never throw (__gdc_begin_catch()
)ECF_MALLOC
: On functions have a malloc-like call (_d_allocmemory
).ECF_PURE
: On functions that return a "new" pointer to GC only. (_d_allocmemory
, others should work, but are a bit risky)ECF_CONST
: On functions that depend solely on its arguments (_d_switch_string
, etc...)Explanation of the fnspec string:
m
: Return value has no aliases1
: First argument same as return value3
: Third argument same as return value.
: Have no idea what is returned.R
: Argument is readonly, not dereferenced recursively, and does not escape.r
: Argument is readonly, and does not escape.W
: Argument is written to, not dereferenced recursively, and does not escape.w
: Argument is written to, but does not escape..
: Have no idea what may be done with argument.