<table border="1" cellspacing="0" cellpadding="8">
<tr>
<th>Issue</th>
<td>
<a href=https://github.com/llvm/llvm-project/issues/107029>107029</a>
</td>
</tr>
<tr>
<th>Summary</th>
<td>
[Clang] Add memory attribute
</td>
</tr>
<tr>
<th>Labels</th>
<td>
enhancement,
clang:frontend
</td>
</tr>
<tr>
<th>Assignees</th>
<td>
</td>
</tr>
<tr>
<th>Reporter</th>
<td>
philnik777
</td>
</tr>
</table>
<pre>
The LLVM IR has a `memory` attribute, which allows specifying memory access for different regions. Specifically, all memory, memory passed via arguments and inaccessible memory. All of these fields can be specified to have (1) no access, (2) read only access, (3) write only access or (4) read/write access. Combining these is also possible. That way it is possible to specify that a function can read/write global memory, but only read argument memory. That allows for really nice optimizations like removing dead calls to functions that only write to some memory (e.g. the `frexp` family of functions). It would be great if clang could expose this flexibility via an attribute. (Except maybe the inaccessible memory part, since that doesn't really seem like a useful concept outside of builtins)
</pre>
<img width="1px" height="1px" alt="" src="http://email.email.llvm.org/o/eJxsVE2PpDYQ_TXmUlrEGLp7OHDozKSllTaXZJV72S6gssZGtuke8usjA70fUk6t9iu_eu9VGYyRB0fUidNv4vRe4JJGH7p5ZOv42-VyKZQ3a_d1JPjy5e8_4POfMGIEBHGuJpp8WMW5AkwpsFoSCfkGj5H1CGitf0SIM2nuV3YD7OWAWlOM0PsAhvueArkEgQb2Lpbw11bPGq1dMxlae1zM_w6KGWMkA3dGwDAsE7kUAZ0Bdjs7K0tHcQlXa8H3kEaKBD2TNRE0OlB0qGMykDyMeCcQ8vVFyBacP4TmtkK-ynwYCA14Z9dfsTpjj8CJfgbBhww2z4tC3vaaHS7hzU-KXU5ml8YR0EYPs98NlPB1xAQPXIFTRp9AFnvkCimXIPSL04m924z90m2wXuHPGaol7TI3N8_8vqe19TyGl2cUKI8CHGsCPyee-F_MnSJY_kYQaPL37MFktjy2mOU99cRd4NZv15O1--k5nZwQlUOZI8gr1Qf6mPNG9TixXfPcvlMJ2ZbwOcHDL9bk6Q2BMAH3oC26AfR2Th-zjwRp5Ai9pQ9WbDmt-7K4H5ta5ta_f2iaE0y4Ktok_M8CwYwh5eAiO027H-MpOiEv6RlPJJr2QBCWSP1iQXu3kfslRTaUraiFbeLNiajeRXUtTFebtm6xoO7lIk-1rGTTFmNX6xO-GNRVXeOrUrpV8nw2vWzw1ZwvVBfc5dKqraSs64tsy9NJqqbBtlGNVqo5iaaiCdmW1t6n0oeh4BgX6l6qSyXbwqIiG7dXLyW5EZ2mvAdCSiHfhJRbpqK-9sG7RM5k4PRehC7zfVLLEEVTWY4p_uiQONntS_K2XT69w9WY7-_-mXyxBNuNKc1R1Fchb0LeBk7jokrtJyFvme74-TQH_w_pJORtUx-FvB0G7p38LwAA__-xCp77">