<div dir="auto">Hi Johannes,<div dir="auto"><br></div><div dir="auto">Thanks for your reply. I now see more clearly how things work with these properties. However, what would be an object whose address is potentially known by a callee? I suppose the intrinsic arguments and global variable?</div><div dir="auto"><br></div><div dir="auto">So IIUC, if not restricted by *only properties, an intrinsic could access to:</div><div dir="auto">- only its arguments if IntrArgMemOnly specified,</div><div dir="auto">- its arguments and the global variable as well if Intr*Mem (other than IntrNoMem) specified.</div><div dir="auto"><br></div><div dir="auto">Please tell me if I'm correct or not!</div><div dir="auto"><br></div><div dir="auto">Thanks again,</div><div dir="auto"><br></div><br><br><div class="gmail_quote" dir="auto"><div dir="ltr" class="gmail_attr">On Wed, Jul 24, 2019, 17:27 Doerfert, Johannes <<a href="mailto:jdoerfert@anl.gov">jdoerfert@anl.gov</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Son Tuan Vu,<br>
<br>
if not restricted by *writeonly*, *readonly*, or *readnone* (basically), a call can access any object for which the<br>
callee could potentially know the address. That means, if the address of an object cannot be known to the callee,<br>
it cannot access that object. An example is given below. Thus, a dead store can be eliminated if the memory cannot<br>
be read by any subsequent operation. If you think there is a bug, could you provide a reproducer?<br>
<br>
Example:<br>
<br>
void unknown();<br>
void foo() {<br>
int *A = malloc(100 * sizeof(A[0]));<br>
int B[100];<br>
for (int i = 0; i < 100; i++)<br>
A[i] = B[i] = i;<br>
<br>
// The addresses/objects A and B are not known to the unknown function and the stores above can be removed.<br>
unknown();<br>
<br>
free(A);<br>
}<br>
<br>
I hope this helps,<br>
Johannes<br>
<br>
<br>
________________________________________<br>
From: llvm-dev <<a href="mailto:llvm-dev-bounces@lists.llvm.org" target="_blank" rel="noreferrer">llvm-dev-bounces@lists.llvm.org</a>> on behalf of Son Tuan VU via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank" rel="noreferrer">llvm-dev@lists.llvm.org</a>><br>
Sent: Wednesday, July 24, 2019 08:20<br>
To: llvm-devmemory<br>
Subject: [llvm-dev] Intrinsics InstrReadMem memory properties<br>
<br>
Hello,<br>
<br>
According to include/llvm/IR/Intrinsics.td, InstrReadMem property indicates that the intrinsic only reads from and does not write to memory.<br>
<br>
Does this mean that it can read anywhere in the memory? Because we already have 'InstrArgMemOnly' for intrinsics which only access memory that its argument(s) point(s) to.<br>
<br>
If 'InstrReadMem' really means read from anywhere in the memory, this should imply that, if there's an intrinsic having this property *after* a dead store, the latter should not be eliminated by optimizations?<br>
<br>
This is not the current behavior of LLVM though, so it seems that my guesses are wrong... But at least, can someone show me the mistake here?<br>
<br>
Thanks for your time,<br>
<br>
Son Tuan Vu<br>
</blockquote></div></div>