<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body>
<p>+1 to the overall proposal. The use case makes sense and is
worth handling. Given the immediate benefit appears to mostly
errno focused, I might have gone with a more specific errnomemonly
flag, but since this proposal is broadly applicable and appears to
solve enough of the errno problem to be useful, this seems fine
too. <br>
</p>
<p>Nicolai raises an important point re: inaccessible memory that
needs clarified in your patches. I think this is mostly a naming
and/or documentation clarity point though. <br>
</p>
<p>I happen to agree with both Nicolai and Johannes that we need to
invert our current memory attribute structure, but as with
Johannes, I would not want to make that blocking for this
proposal.</p>
<p>Philip<br>
</p>
<div class="moz-cite-prefix">On 9/11/21 12:16 PM, Mugilan Ganesan
via llvm-dev wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAK6LgtoQsuS3Hotff5XT_9jWregmTzPTGEHaL0ddOnSDEuX9ZA@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="ltr">
Hello everyone,<br>
<br>
We propose the addition of a GlobalMemOnly attribute to LLVM.<br>
<br>
Definition:<br>
<br>
This attribute indicates that the only memory accessed inside a
function, that is visible to the callee, is global memory. If
the function reads or writes other memory that is visible to the
callee, the behavior is undefined.<br>
<br>
Motivation:<br>
<br>
Memory attributes already exist for specifying the memory
locations accessed by a function, such as ArgMemOnly and
InacessibleMemOnly. Similarly, there are attributes for
describing memory behaviour, such as ReadOnly and WriteOnly.<br>
<br>
However, no attributes exist for differentiating the types of
memory objects that functions can access, such as global objects
and objects created by alloca. We would like to start by
introducing an attribute to deal with functions that only access
global objects.<br>
<br>
The addition of the GlobalMemOnly attribute can benefit LLVM as
follows:<br>
<br>
1. Improves Alias Analysis, since this information can be used
to improve the determination of aliasing between functions and
memory locations that point to global objects.<br>
<div><br>
</div>
<div>2. Provides Transforms with greater information: many math
lib calls only modify the global variable errno. Unnecessary
loads of the call arguments can therefore be removed, since
the calls will have no side-effects on them.</div>
<br>
Patches Overview:<br>
<br>
1. Definition of GlobalMemOnly in the AsmParser, IR, and LLVM
Bitcode. It is also defined in the LangRef.<br>
<br>
<a href="https://reviews.llvm.org/D109644" target="_blank"
moz-do-not-send="true">https://reviews.llvm.org/D109644</a><br>
<br>
2. Support is added to Alias Analysis. If a function is
GlobalMemOnly and a memory location does not point to a global
object, getModRefInfo can infer that no aliasing between the
function and the location can occur. This patch also adds a
regression test for BasicAA.<br>
<br>
<a href="https://reviews.llvm.org/D109647" target="_blank"
moz-do-not-send="true">https://reviews.llvm.org/D109647</a><br>
<br>
3. Certain math lib calls are assigned GlobalMemOnly, since they
only modify the global variable errno. These calls include
common functions, such as atan, exp, and log.<br>
<br>
<a href="https://reviews.llvm.org/D109648" target="_blank"
moz-do-not-send="true">https://reviews.llvm.org/D109648</a><br>
<br>
Please let us know of any thoughts you may have regarding this
attribute’s implementation and use cases. We believe that it can
strengthen LLVM’s alias analysis and optimization passes if
added.<br>
<br>
Thanks,<br>
Mugilan</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
LLVM Developers mailing list
<a class="moz-txt-link-abbreviated" href="mailto:llvm-dev@lists.llvm.org">llvm-dev@lists.llvm.org</a>
<a class="moz-txt-link-freetext" href="https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
</body>
</html>