<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On 27 February 2015 at 09:57, Owen Anderson <span dir="ltr"><<a href="mailto:resistor@mac.com" target="_blank">resistor@mac.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: resistor<br>
Date: Fri Feb 27 11:57:01 2015<br>
New Revision: 230769<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=230769&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=230769&view=rev</a><br>
Log:<br>
Switch a std::map to a DenseMap in CodeGenRegisters.<br>
<br>
The keys of the map are unique by pointer address, so there's no need<br>
to use the llvm::less comparator. This allows us to use DenseMap<br>
instead, which reduces tblgen time by 20% on my stress test.<br>
<br>
Modified:<br>
llvm/trunk/utils/TableGen/CodeGenRegisters.cpp<br>
llvm/trunk/utils/TableGen/CodeGenRegisters.h<br>
llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp<br>
<br>
Modified: llvm/trunk/utils/TableGen/CodeGenRegisters.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenRegisters.cpp?rev=230769&r1=230768&r2=230769&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenRegisters.cpp?rev=230769&r1=230768&r2=230769&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/utils/TableGen/CodeGenRegisters.cpp (original)<br>
+++ llvm/trunk/utils/TableGen/CodeGenRegisters.cpp Fri Feb 27 11:57:01 2015<br>
@@ -258,6 +258,8 @@ CodeGenRegister::computeSubRegs(CodeGenR<br>
<br>
// Look at the possible compositions of Idx.<br>
// They may not all be supported by SR.<br>
+ // NOTE: Iteration order does not matter here because the EnumValue's<br>
+ // of subreg indices are unique.<br></blockquote><div><br></div><div>I think this introduced non-determinism. This iteration order changes the order of which items get evaluted to be put into Indices which is a vector, and that feeds into other things. The net result is that one build of clang has these symbols:</div><div><br></div><div><div>00000000012b0a50 t _ZN4llvmL51QQQQPR_with_dsub_2_then_ssub_0GetRawAllocationOrderERKNS_15MachineFunctionE</div><div>00000000012b0a60 t _ZN4llvmL51QQQQPR_with_dsub_5_then_ssub_0GetRawAllocationOrderERKNS_15MachineFunctionE</div><div>00000000012b0a70 t _ZN4llvmL51QQQQPR_with_dsub_7_then_ssub_0GetRawAllocationOrderERKNS_15MachineFunctionE</div></div><div><br></div><div>while the other has these:</div><div><br></div><div><div>00000000012b0a50 t _ZN4llvmL51QQQQPR_with_dsub_2_then_ssub_0GetRawAllocationOrderERKNS_15MachineFunctionE</div><div>00000000012b0a60 t _ZN4llvmL51QQQQPR_with_dsub_4_then_ssub_0GetRawAllocationOrderERKNS_15MachineFunctionE</div><div>00000000012b0a70 t _ZN4llvmL51QQQQPR_with_dsub_6_then_ssub_0GetRawAllocationOrderERKNS_15MachineFunctionE</div></div><div><br></div><div>That difference is a bootstrap miscompare. Besides the symbol names, every instruction is identical.</div><div><br></div><div>Let me know if you'd like me help debugging further. I'm going to partially revert only this comment and the typedef change in CodeGenRegisters.h, since the rest is code cleanup.</div><div><br></div><div>Nick</div><div><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
for (CodeGenSubRegIndex::CompMap::const_iterator I = Comps.begin(),<br>
E = Comps.end(); I != E; ++I) {<br>
SubRegMap::const_iterator SRI = Map.find(I->first);<br>
<br>
Modified: llvm/trunk/utils/TableGen/CodeGenRegisters.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenRegisters.h?rev=230769&r1=230768&r2=230769&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenRegisters.h?rev=230769&r1=230768&r2=230769&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/utils/TableGen/CodeGenRegisters.h (original)<br>
+++ llvm/trunk/utils/TableGen/CodeGenRegisters.h Fri Feb 27 11:57:01 2015<br>
@@ -74,8 +74,7 @@ namespace llvm {<br>
std::string getQualifiedName() const;<br>
<br>
// Map of composite subreg indices.<br>
- typedef std::map<CodeGenSubRegIndex *, CodeGenSubRegIndex *,<br>
- deref<llvm::less>> CompMap;<br>
+ typedef DenseMap<CodeGenSubRegIndex *, CodeGenSubRegIndex *> CompMap;<br>
<br>
// Returns the subreg index that results from composing this with Idx.<br>
// Returns NULL if this and Idx don't compose.<br>
<br>
Modified: llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=230769&r1=230768&r2=230769&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp?rev=230769&r1=230768&r2=230769&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp (original)<br>
+++ llvm/trunk/utils/TableGen/RegisterInfoEmitter.cpp Fri Feb 27 11:57:01 2015<br>
@@ -610,17 +610,19 @@ static void printMask(raw_ostream &OS, u<br>
static bool combine(const CodeGenSubRegIndex *Idx,<br>
SmallVectorImpl<CodeGenSubRegIndex*> &Vec) {<br>
const CodeGenSubRegIndex::CompMap &Map = Idx->getComposites();<br>
- for (CodeGenSubRegIndex::CompMap::const_iterator<br>
- I = Map.begin(), E = Map.end(); I != E; ++I) {<br>
- CodeGenSubRegIndex *&Entry = Vec[I->first->EnumValue - 1];<br>
- if (Entry && Entry != I->second)<br>
+ for (const auto &I : Map) {<br>
+ CodeGenSubRegIndex *&Entry = Vec[I.first->EnumValue - 1];<br>
+ if (Entry && Entry != I.second)<br>
return false;<br>
}<br>
<br>
// All entries are compatible. Make it so.<br>
- for (CodeGenSubRegIndex::CompMap::const_iterator<br>
- I = Map.begin(), E = Map.end(); I != E; ++I)<br>
- Vec[I->first->EnumValue - 1] = I->second;<br>
+ for (const auto &I : Map) {<br>
+ auto *&Entry = Vec[I.first->EnumValue - 1];<br>
+ assert((!Entry || Entry == I.second) &&<br>
+ "Expected EnumValue to be unique");<br>
+ Entry = I.second;<br>
+ }<br>
return true;<br>
}<br>
<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>