<html dir="ltr">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
</head>
<body ocsi="0" fpstyle="1" bgcolor="#FFFFFF">
<div style="direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;">Hi Richard,<br>
The code has been changed to handle duplicate constant expressions in the phi instruction  (only triggers under O0).<br>
Robert<br>
<br>
<div style="font-family: Times New Roman; color: #000000; font-size: 16px">
<hr tabindex="-1">
<div style="direction: ltr;" id="divRpF444239"><font color="#000000" face="Tahoma" size="2"><b>From:</b> Richard Osborne<br>
<b>Sent:</b> 23 September 2013 18:22<br>
<b>To:</b> Robert Lytton<br>
<b>Cc:</b> llvm-commits@cs.uiuc.edu<br>
<b>Subject:</b> Re: XCore target: fix bug in XCoreLowerThreadLocal.cpp<br>
</font><br>
</div>
<div></div>
<div>
<div class="moz-cite-prefix">Hi Robert,<br>
<br>
+          // in the calling BB, infront of the branch instruction.<br>
<br>
calling BB doesn't seem the right terminology, how about: in the predecessor, before the branch instruction.<br>
<br>
+          if (PHINode *PN = dyn_cast<PHINode>(WU))<br>
+            for (int I=0, E=PN->getNumIncomingValues(); I < E; ++I)<br>
+              if (PN->getIncomingValue(I) == CE) {<br>
+                InsertPos = &PN->getIncomingBlock(I)->back();<br>
+                break;<br>
+              }<br>
+          Instruction *NewInst = createReplacementInstr(CE, InsertPos);<br>
<br>
What happens if the constant expression appears twice in the phi instruction? Also there should be spaces around '='<br>
<br>
On 23/09/13 17:59, Robert Lytton wrote:<br>
</div>
<blockquote type="cite"><style id="owaParaStyle" type="text/css">
<!--
p
        {margin-top:0;
        margin-bottom:0}
-->
BODY {direction: ltr;font-family: Tahoma;color: #000000;font-size: 10pt;}P {margin-top:0;margin-bottom:0;}</style>
<div style="direction:ltr; font-family:Tahoma; color:#000000; font-size:10pt">Hi,<br>
<br>
Attached is a patch to fix:<br>
<br>
   XCore target: fix bug in XCoreLowerThreadLocal.cpp<br>
    <br>
    When a ConstantExpr which uses a thread local is part of a PHI node<br>
    instruction, the insruction that replaces the ConstantExpr must<br>
    be inserted in the calling block just before the branch instruction.<br>
<br>
<br>
Robert<br>
</div>
</blockquote>
<br>
<br>
<pre class="moz-signature" cols="72">-- 
Richard Osborne | XMOS
<a class="moz-txt-link-freetext" href="http://www.xmos.com" target="_blank">http://www.xmos.com</a>
</pre>
</div>
</div>
</div>
</body>
</html>