Changes in directory llvm/utils/TableGen:
DAGISelEmitter.cpp updated: 1.205 -> 1.206 --- Log message: Fixed a really ugly bug. The TableGen'd isel is not freeing the "inflight set" correctly. That is causing non-deterministic behavior (and possibly preventing some load folding from happening). --- Diffs of the changes: (+21 -9) DAGISelEmitter.cpp | 30 +++++++++++++++++++++--------- 1 files changed, 21 insertions(+), 9 deletions(-) Index: llvm/utils/TableGen/DAGISelEmitter.cpp diff -u llvm/utils/TableGen/DAGISelEmitter.cpp:1.205 llvm/utils/TableGen/DAGISelEmitter.cpp:1.206 --- llvm/utils/TableGen/DAGISelEmitter.cpp:1.205 Fri May 19 02:24:32 2006 +++ llvm/utils/TableGen/DAGISelEmitter.cpp Wed May 24 19:21:44 2006 @@ -2407,20 +2407,32 @@ std::string Fn = CP->getSelectFunc(); NumRes = CP->getNumOperands(); for (unsigned i = 0; i < NumRes; ++i) - emitDecl("Tmp" + utostr(i+ResNo)); + emitDecl("CPTmp" + utostr(i+ResNo)); - std::string Code = Fn + "(" + Val; + std::string Code = "bool Match = " + Fn + "(" + Val; for (unsigned i = 0; i < NumRes; i++) - Code += ", Tmp" + utostr(i + ResNo); - emitCheck(Code + ")"); + Code += ", CPTmp" + utostr(i + ResNo); + emitCode(Code + ");"); + if (InflightNodes.size()) { + // Remove the in-flight nodes if the ComplexPattern does not match! + emitCode("if (!Match) {"); + for (std::vector<std::string>::iterator AI = InflightNodes.begin(), + AE = InflightNodes.end(); AI != AE; ++AI) + emitCode(" InFlightSet.erase(" + *AI + ".Val);"); + emitCode("}"); + } + + emitCheck("Match"); for (unsigned i = 0; i < NumRes; ++i) { - emitCode("InFlightSet.insert(Tmp" + utostr(i+ResNo) + ".Val);"); - InflightNodes.push_back("Tmp" + utostr(i+ResNo)); + emitCode("InFlightSet.insert(CPTmp" + utostr(i+ResNo) + ".Val);"); + InflightNodes.push_back("CPTmp" + utostr(i+ResNo)); } - for (unsigned i = 0; i < NumRes; ++i) - emitCode("Select(Tmp" + utostr(i+ResNo) + ", Tmp" + + for (unsigned i = 0; i < NumRes; ++i) { + emitDecl("Tmp" + utostr(i+ResNo)); + emitCode("Select(Tmp" + utostr(i+ResNo) + ", CPTmp" + utostr(i+ResNo) + ");"); + } TmpNo = ResNo + NumRes; } else { @@ -2524,7 +2536,6 @@ // Make sure these operands which would be selected won't be folded while // the isel traverses the DAG upward. - std::vector<std::pair<unsigned, unsigned> > NumTemps(EmitOrder.size()); for (unsigned i = 0, e = EmitOrder.size(); i != e; ++i) { TreePatternNode *Child = EmitOrder[i].second; if (!Child->getName().empty()) { @@ -2539,6 +2550,7 @@ } // Emit all of the operands. + std::vector<std::pair<unsigned, unsigned> > NumTemps(EmitOrder.size()); for (unsigned i = 0, e = EmitOrder.size(); i != e; ++i) { unsigned OpOrder = EmitOrder[i].first; TreePatternNode *Child = EmitOrder[i].second; _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits