<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=Windows-1252">
</head>
<body text="#000000" bgcolor="#FFFFFF">
<br>
<div class="moz-cite-prefix">On 11/18/2018 08:02 AM, De Azevedo Piovezan, Felipe via llvm-dev wrote:<br>
</div>
<blockquote type="cite" cite="mid:A18E5F8395391E4490DFB8586DAF6E6C01218417@ORSMSX108.amr.corp.intel.com">
<meta name="Generator" content="Microsoft Word 15 (filtered
        medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        margin-bottom:.0001pt;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
        {mso-style-priority:99;
        color:#0563C1;
        text-decoration:underline;}
a:visited, span.MsoHyperlinkFollowed
        {mso-style-priority:99;
        color:#954F72;
        text-decoration:underline;}
span.EmailStyle17
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
<div class="WordSection1">
<p class="MsoNormal">Hi,<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Does this kind of IR have “undefined behavior”  under LLVM semantics or is it acceptable?<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">(TLDR: a store of i64 at offset n, followed by a load of i32 at offset n+1.)</p>
</div>
</blockquote>
<br>
Yes, this is well-defined at the IR level. It might have been undefined at the source level, and that might have been translated into TBAA metadata at the LLVM level which would have rendered it undefined at the IR level, but I see no aliasing metadata here.<br>
<br>
 -Hal<br>
<br>
<blockquote type="cite" cite="mid:A18E5F8395391E4490DFB8586DAF6E6C01218417@ORSMSX108.amr.corp.intel.com">
<div class="WordSection1">
<p class="MsoNormal"><o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">define void @foo(i32* %A, i64 %n) {<o:p></o:p></p>
<p class="MsoNormal">entry:<o:p></o:p></p>
<p class="MsoNormal">  %arrayidx = getelementptr inbounds i32, i32* %A, i64 %n<o:p></o:p></p>
<p class="MsoNormal">  %arrayidx_cast = bitcast i32* %arrayidx to i64*<o:p></o:p></p>
<p class="MsoNormal">  store i64 0, i64* %arrayidx_cast, align 4<o:p></o:p></p>
<p class="MsoNormal">  %add1 = add i64 %n, 1<o:p></o:p></p>
<p class="MsoNormal">  %arrayidx2 = getelementptr inbounds i32, i32* %A, i64 %add1<o:p></o:p></p>
<p class="MsoNormal">  %0 = load i32, i32* %arrayidx2, align 4<o:p></o:p></p>
<p class="MsoNormal">  ret void<o:p></o:p></p>
<p class="MsoNormal">}<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The result of Dependence Analysis is:<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">opt -analyze -da BitCasts.ll <o:p></o:p></p>
<p class="MsoNormal">Printing analysis 'Dependence Analysis' for function 'z0':<o:p></o:p></p>
<p class="MsoNormal">da analyze - none!          <<< this is between the store and itself, ok to be “none”.<o:p></o:p></p>
<p class="MsoNormal">da analyze - none!          <<< this is between the store and the load!!!<o:p></o:p></p>
<p class="MsoNormal">da analyze - none!          <<< this is between the load and itself, ok to be “none”.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Is dependence analysis right or wrong? This IR likely comes from some C++ code doing funny things with unions…<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks!<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">--<o:p></o:p></p>
<p class="MsoNormal">Felipe de Azevedo Piovezan<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset> <br>
<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="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-dev</a>
</pre>
</blockquote>
<br>
<pre class="moz-signature" cols="72">-- 
Hal Finkel
Lead, Compiler Technology and Programming Languages
Leadership Computing Facility
Argonne National Laboratory</pre>
</body>
</html>