<HTML><BODY style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><DIV><BR><DIV>Begin forwarded message:</DIV><BR class="Apple-interchange-newline"><BLOCKQUOTE type="cite"><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT face="Helvetica" size="3" color="#000000" style="font: 12.0px Helvetica; color: #000000"><B>Date: </B></FONT><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica">May 23, 2007 8:31:01 AM PDT</FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT face="Helvetica" size="3" color="#000000" style="font: 12.0px Helvetica; color: #000000"><B>To: </B></FONT><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica"><A href="mailto:llvm-group@group.apple.com">llvm-group@group.apple.com</A></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><FONT face="Helvetica" size="3" color="#000000" style="font: 12.0px Helvetica; color: #000000"><B>Subject: </B></FONT><FONT face="Helvetica" size="3" style="font: 12.0px Helvetica"><B>[127591] Fix PR1404.</B></FONT></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV> <DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Revision: 127591</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Author: <SPAN class="Apple-converted-space">  </SPAN>dpatel</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Date: <SPAN class="Apple-converted-space">    </SPAN>2007-05-23 08:31:00 -0700 (Wed, 23 May 2007)</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Log Message:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">-----------</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Fix PR1404. Patch by Duncan Sands.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Prune local values from LLVMValues vector.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Modified Paths:</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">--------------</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">    </SPAN>apple-local/branches/llvm/gcc/llvm-convert.cpp</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">Modified: apple-local/branches/llvm/gcc/llvm-convert.cpp</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">===================================================================</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">--- apple-local/branches/llvm/gcc/llvm-convert.cpp<SPAN class="Apple-tab-span" style="white-space:pre">     </SPAN>2007-05-23 09:21:47 UTC (rev 127590)</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+++ apple-local/branches/llvm/gcc/llvm-convert.cpp<SPAN class="Apple-tab-span" style="white-space:pre">  </SPAN>2007-05-23 15:31:00 UTC (rev 127591)</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">@@ -128,7 +128,8 @@</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">     </SPAN>// If there was an error, we may have disabled creating LLVM values.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">     </SPAN>if (Index == 0) return 0;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">   </SPAN>}</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">-<SPAN class="Apple-converted-space">  </SPAN>assert ((Index - 1) < LLVMValues.size() && "Invalid LLVM Value index");</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">  </SPAN>assert ((Index - 1) < LLVMValues.size() && "Invalid LLVM value index");</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">  </SPAN>assert (LLVMValues[Index - 1] && "Trying to use deleted LLVM value!");</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">   </SPAN>return LLVMValues[Index - 1];</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space"> </SPAN>}</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">@@ -153,7 +154,8 @@</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">   </SPAN>// Insert the new value into the value map.<SPAN class="Apple-converted-space">  </SPAN>We know that it can't already</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">   </SPAN>// exist in the mapping.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">-<SPAN class="Apple-converted-space">  </SPAN>LLVMValuesMap[New] = Idx+1;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">  </SPAN>if (New)</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">    </SPAN>LLVMValuesMap[New] = Idx+1;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space"> </SPAN>}</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space"> </SPAN>// Read LLVM Types string table</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">@@ -198,7 +200,7 @@</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">   </SPAN>for (std::vector<Value *>::iterator I = LLVMValues.begin(),</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">          </SPAN>E = LLVMValues.end(); I != E; ++I)<SPAN class="Apple-converted-space">  </SPAN>{</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">-<SPAN class="Apple-converted-space">    </SPAN>if (Constant *C = dyn_cast<Constant>(*I))</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">    </SPAN>if (Constant *C = dyn_cast_or_null<Constant>(*I))</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">       </SPAN>ValuesForPCH.push_back(C);</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">     </SPAN>else</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">       </SPAN>// Non constant values, e.g. arguments, are not at global scope.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">@@ -216,6 +218,36 @@</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">                      </SPAN>"llvm.pch.values", TheModule);</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space"> </SPAN>}</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+/// eraseLocalLLVMValues - drop all non-global values from the LLVM values map.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+void eraseLocalLLVMValues() {</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">  </SPAN>// Try to reduce the size of LLVMValues by removing local values from the end.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">  </SPAN>std::vector<Value *>::reverse_iterator I, E;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">  </SPAN>for (I = LLVMValues.rbegin(), E = LLVMValues.rend(); I != E; ++I) {</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">    </SPAN>if (Value *V = *I) {</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">      </SPAN>if (isa<Constant>(V))</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">        </SPAN>break;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">      </SPAN>else</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">        </SPAN>LLVMValuesMap.erase(V);</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">    </SPAN>}</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">  </SPAN>}</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">  </SPAN>LLVMValues.erase(I.base(), LLVMValues.end()); // Drop erased values</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">  </SPAN>// Iterate over LLVMValuesMap since it may be much smaller than LLVMValues.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">  </SPAN>for (LLVMValuesMapTy::iterator I = LLVMValuesMap.begin(),</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+ <SPAN class="Apple-converted-space">      </SPAN>E = LLVMValuesMap.end(); I != E; ++I) {</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">    </SPAN>assert(I->first && "Values map contains NULL!");</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">    </SPAN>if (!isa<Constant>(I->first)) {</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">      </SPAN>unsigned Index = I->second - 1;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">      </SPAN>assert(Index < LLVMValues.size() && LLVMValues[Index] == I->first &&</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+ <SPAN class="Apple-converted-space">            </SPAN>"Inconsistent value map!");</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">      </SPAN>LLVMValues[Index] = NULL;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">      </SPAN>LLVMValuesMap.erase(I);</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">    </SPAN>}</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">  </SPAN>}</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+}</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space"> </SPAN>/// isGCC_SSA_Temporary - Return true if this is an SSA temporary that we can</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space"> </SPAN>/// directly compile into an LLVM temporary.<SPAN class="Apple-converted-space">  </SPAN>This saves us from creating an</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space"> </SPAN>/// alloca and creating loads/stores of that alloca (a compile-time win).<SPAN class="Apple-converted-space">  </SPAN>We</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">@@ -689,7 +721,11 @@</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">     </SPAN>if (SI->getNumSuccessors() > 1)</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">       </SPAN>SI->setSuccessor(0, SI->getSuccessor(1));</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">   </SPAN>}</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">- <SPAN class="Apple-converted-space"> </SPAN></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">  </SPAN>// Remove any cached LLVM values that are local to this function.<SPAN class="Apple-converted-space">  </SPAN>Such values</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">  </SPAN>// may be deleted when the optimizers run, so would be dangerous to keep.</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+<SPAN class="Apple-converted-space">  </SPAN>eraseLocalLLVMValues();</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; ">+</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space">   </SPAN>return Fn;</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; "><SPAN class="Apple-converted-space"> </SPAN>}</DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV><DIV style="margin-top: 0px; margin-right: 0px; margin-bottom: 0px; margin-left: 0px; min-height: 14px; "><BR></DIV> </BLOCKQUOTE></DIV><BR></BODY></HTML>