llvm.org GIT mirror llvm / 72e4d4b
Merge from mainline. Fix non-determinism in DAGISel emitter. - This manifested as non-determinism in the .inc output in rare cases (when two distinct patterns ended up being equivalent, which is rather rare). That meant the pattern matching was non-deterministic, which could eventually mean the code generator selected different instructions based on the arch. - It's probably worth making the DAGISel ensure a total ordering (or force the user to), but the simple fix here is to totally order the Record* maps based on a unique ID. - PR4672, PR4711. git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_26@80543 91177308-0d34-0410-b5e6-96231b3b80d8 Tanya Lattner 9 years ago
4 changed file(s) with 23 addition(s) and 7 deletion(s). Raw diff Collapse all Expand all
9999 } // end namespace EEVT.
100100 } // end namespace llvm.
101101
102 bool RecordPtrCmp::operator()(const Record *LHS, const Record *RHS) const {
103 return LHS->getID() < RHS->getID();
104 }
102105
103106 /// Dependent variable map for CodeGenDAGPattern variant generation
104107 typedef std::map DepVarMap;
461461 std::string getPredicateCheck() const;
462462 };
463463
464 // Deterministic comparison of Record*.
465 struct RecordPtrCmp {
466 bool operator()(const Record *LHS, const Record *RHS) const;
467 };
464468
465469 class CodeGenDAGPatterns {
466470 RecordKeeper &Records;
468472 std::vector Intrinsics;
469473 std::vector TgtIntrinsics;
470474
471 std::map SDNodes;
472 std::map > SDNodeXForms;
473 std::map ComplexPatterns;
474 std::map PatternFragments;
475 std::map DefaultOperands;
476 std::mapDAGInstruction> Instructions;
475 std::mapSDNodeInfo, RecordPtrCmp> SDNodes;
476 std::map, RecordPtrCmp> SDNodeXForms;
477 std::map ComplexPatterns;
478 std::map PatternFragments;
479 std::map DefaultOperands;
480 std::map Instructions;
477481
478482 // Specific SDNode definitions:
479483 Record *intrinsic_void_sdnode;
13181318 if (PrintSem) OS << ";\n";
13191319 }
13201320
1321 unsigned Record::LastID = 0;
1322
13211323 void Record::setName(const std::string &Name) {
13221324 if (Records.getDef(getName()) == this) {
13231325 Records.removeDef(getName());
12191219 }
12201220
12211221 class Record {
1222 static unsigned LastID;
1223
1224 // Unique record ID.
1225 unsigned ID;
12221226 std::string Name;
12231227 SMLoc Loc;
12241228 std::vector TemplateArgs;
12261230 std::vector SuperClasses;
12271231 public:
12281232
1229 explicit Record(const std::string &N, SMLoc loc) : Name(N), Loc(loc) {}
1233 explicit Record(const std::string &N, SMLoc loc) :
1234 ID(LastID++), Name(N), Loc(loc) {}
12301235 ~Record() {}
12311236
1237 unsigned getID() const { return ID; }
1238
12321239 const std::string &getName() const { return Name; }
12331240 void setName(const std::string &Name); // Also updates RecordKeeper.
12341241