<div dir="ltr"><br><div class="gmail_extra"><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">I used -O3. I will try <span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">MemorySSA analysis. Thanks!</span></span></div><div class="gmail_extra"><br></div><div class="gmail_extra"><div><div class="m_3267309271191982723gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><br></div><div>Best regards,</div><div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Qiuping Yi</div><div style="font-size:12.8px"><span style="font-size:12.8px">Institute Of Software</span><br style="font-size:12.8px"><span style="font-size:12.8px">Chinese Academy of Sciences</span><br></div></div></div></div></div></div></div></div></div></div>
<br><div class="gmail_quote">On Thu, Feb 8, 2018 at 2:26 PM, Daniel Berlin <span dir="ltr"><<a href="mailto:dberlin@dberlin.org" target="_blank">dberlin@dberlin.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div><br></div><div>Let me try to help.</div><div class="gmail_extra"><br><div class="gmail_quote"><span>On Thu, Feb 8, 2018 at 12:13 PM, Qiuping Yi via llvm-dev <span dir="ltr"><<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>Thanks for your explanation. </div><div><br></div>Do you mean that LLVM will not maintain the def-use chain for atomic variables?</div></blockquote></span><div>It is not a variable at the LLVM level.</div><div>At the source level, it is a variable.</div><div>At the LLVM IR level, it is lowered into memory operations.</div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">All of your operations were. None of them are in llvm registers.</span><br></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">Some were then promoted or partially promoted into registers.</span></div><div><span style="color:rgb(34,34,34);font-family:arial,sans-serif;font-size:small;font-style:normal;font-variant-ligatures:normal;font-variant-caps:normal;font-weight:400;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px;background-color:rgb(255,255,255);text-decoration-style:initial;text-decoration-color:initial;float:none;display:inline">(it looks like your output is -O1 or something and uses libstdc++ instead of libc++)</span></div></div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div>The loads are loads from a memory location.  It does not have any more data dependence info than your atomics.<br></div><div><br></div><div>The phi you are seeing is not "LLVM giving you data dependence info".</div><div><br></div><div>Memory is not in SSA form in LLVM and has no def use chains by default.</div><div><br></div><div>If you want an SSA form for Memory, you would have to use the MemorySSA analysis.</div><span><div><br></div><div> <br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div>So it is impossible to directly catch the fact that the load of x at the statement 'data1 = x; ' dependents on data4 (because of the statement x=data4 )? <br></div><div><div>If I want to get such information, may be the only solution is to traverse all the predecessors of the statement 'data1 = x;'. <br class="m_3267309271191982723m_5983482015478174834m_-8773427658199693752gmail-Apple-interchange-newline"></div></div></div></blockquote><div><br></div></span><div>This will not work either in general. </div></div></div></div></blockquote><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><div class="gmail_extra"><div class="gmail_quote"><div> </div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span><div dir="ltr"><div><div><br></div></div></div><div class="gmail_extra"><span><br clear="all"><div><div class="m_3267309271191982723m_5983482015478174834m_-8773427658199693752gmail_signature" data-smartmail="gmail_signature"><div dir="ltr"><div><div dir="ltr"><div dir="ltr"><div dir="ltr"><div dir="ltr"><div><br></div><div>Best regards,</div><div><div style="font-size:12.8px"><br></div><div style="font-size:12.8px">Qiuping Yi</div><div style="font-size:12.8px"><span style="font-size:12.8px">Institute Of Software</span><br style="font-size:12.8px"><span style="font-size:12.8px">Chinese Academy of Sciences</span><br></div></div></div></div></div></div></div></div></div></div>
<br></span><span><div class="gmail_quote">On Thu, Feb 8, 2018 at 3:11 AM, David Chisnall <span dir="ltr"><<a href="mailto:David.Chisnall@cl.cam.ac.uk" target="_blank">David.Chisnall@cl.cam.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On 8 Feb 2018, at 04:07, Qiuping Yi via llvm-dev <<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a>> wrote:<br>
><br>
> I found that it only generated PHI node (%8 = phi i32 [ %4, %3 ], [ %6, %5 ]) for non-atomic variable 'data2' but not for atomic variable x? Why?<br>
<br>
</span>LLVM IR does not contain variables, it contains (immutable) registers.  Some of these registers refer to memory locations and are usable with loads and stores.  The notion of ‘atomic’ doesn’t make sense in the context of a register, because registers are implicitly immutable (i.e. not updated, so atomic updates don’t make sense) and non-shared (so there’s nothing for accesses to them to be atomic with respect to).  As such, the atomic qualifier makes sense only with memory locations.  The memory address itself may be stored in a register, but updates to the location must be performed by loads and stores (or atomicrmw instructions).<br>
<br>
In the absence of any ordering constraints imposed by atomic memory operations (including fences), it is often safe to promote a sequence of loads and stores of a memory location to a single load / store pair with a sequence of registers storing temporary values.  This is allowed because, in the absence of something that establishes a happens-before relationship between threads, a thread is allowed to make writes to memory visible to other threads in any order.<br>
<span class="m_3267309271191982723m_5983482015478174834m_-8773427658199693752HOEnZb"><font color="#888888"><br>
David<br>
<br>
</font></span></blockquote></div><br></span></div>
<br></span>______________________________<wbr>_________________<br>
LLVM Developers mailing list<br>
<a href="mailto:llvm-dev@lists.llvm.org" target="_blank">llvm-dev@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/llvm-dev</a><br>
<br></blockquote></div><br></div></div>
</blockquote></div><br></div></div>