diff options
author | Tanya Lattner <tonic@nondot.org> | 2009-08-31 06:12:11 +0000 |
---|---|---|
committer | Tanya Lattner <tonic@nondot.org> | 2009-08-31 06:12:11 +0000 |
commit | 72e4d4b370b44fc02f4bd3370b99393ba8052170 (patch) | |
tree | 7069c65acdf8e1451257b888d4e499a0d94c4b79 /utils/TableGen | |
parent | a729daf695c66532793f72d69a7c27404119bd6c (diff) |
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
Diffstat (limited to 'utils/TableGen')
-rw-r--r-- | utils/TableGen/CodeGenDAGPatterns.cpp | 3 | ||||
-rw-r--r-- | utils/TableGen/CodeGenDAGPatterns.h | 16 | ||||
-rw-r--r-- | utils/TableGen/Record.cpp | 2 | ||||
-rw-r--r-- | utils/TableGen/Record.h | 9 |
4 files changed, 23 insertions, 7 deletions
diff --git a/utils/TableGen/CodeGenDAGPatterns.cpp b/utils/TableGen/CodeGenDAGPatterns.cpp index efa7fe4ae9..9fa6a09202 100644 --- a/utils/TableGen/CodeGenDAGPatterns.cpp +++ b/utils/TableGen/CodeGenDAGPatterns.cpp @@ -100,6 +100,9 @@ bool isExtVectorInVTs(const std::vector<unsigned char> &EVTs) { } // end namespace EEVT. } // end namespace llvm. +bool RecordPtrCmp::operator()(const Record *LHS, const Record *RHS) const { + return LHS->getID() < RHS->getID(); +} /// Dependent variable map for CodeGenDAGPattern variant generation typedef std::map<std::string, int> DepVarMap; diff --git a/utils/TableGen/CodeGenDAGPatterns.h b/utils/TableGen/CodeGenDAGPatterns.h index 56dcfcff91..f7198d8ae5 100644 --- a/utils/TableGen/CodeGenDAGPatterns.h +++ b/utils/TableGen/CodeGenDAGPatterns.h @@ -462,6 +462,10 @@ struct PatternToMatch { std::string getPredicateCheck() const; }; +// Deterministic comparison of Record*. +struct RecordPtrCmp { + bool operator()(const Record *LHS, const Record *RHS) const; +}; class CodeGenDAGPatterns { RecordKeeper &Records; @@ -469,12 +473,12 @@ class CodeGenDAGPatterns { std::vector<CodeGenIntrinsic> Intrinsics; std::vector<CodeGenIntrinsic> TgtIntrinsics; - std::map<Record*, SDNodeInfo> SDNodes; - std::map<Record*, std::pair<Record*, std::string> > SDNodeXForms; - std::map<Record*, ComplexPattern> ComplexPatterns; - std::map<Record*, TreePattern*> PatternFragments; - std::map<Record*, DAGDefaultOperand> DefaultOperands; - std::map<Record*, DAGInstruction> Instructions; + std::map<Record*, SDNodeInfo, RecordPtrCmp> SDNodes; + std::map<Record*, std::pair<Record*, std::string>, RecordPtrCmp> SDNodeXForms; + std::map<Record*, ComplexPattern, RecordPtrCmp> ComplexPatterns; + std::map<Record*, TreePattern*, RecordPtrCmp> PatternFragments; + std::map<Record*, DAGDefaultOperand, RecordPtrCmp> DefaultOperands; + std::map<Record*, DAGInstruction, RecordPtrCmp> Instructions; // Specific SDNode definitions: Record *intrinsic_void_sdnode; diff --git a/utils/TableGen/Record.cpp b/utils/TableGen/Record.cpp index 8f31624644..d594c9aa09 100644 --- a/utils/TableGen/Record.cpp +++ b/utils/TableGen/Record.cpp @@ -1319,6 +1319,8 @@ void RecordVal::print(raw_ostream &OS, bool PrintSem) const { if (PrintSem) OS << ";\n"; } +unsigned Record::LastID = 0; + void Record::setName(const std::string &Name) { if (Records.getDef(getName()) == this) { Records.removeDef(getName()); diff --git a/utils/TableGen/Record.h b/utils/TableGen/Record.h index 40c8239b9a..9415109dbb 100644 --- a/utils/TableGen/Record.h +++ b/utils/TableGen/Record.h @@ -1220,6 +1220,10 @@ inline raw_ostream &operator<<(raw_ostream &OS, const RecordVal &RV) { } class Record { + static unsigned LastID; + + // Unique record ID. + unsigned ID; std::string Name; SMLoc Loc; std::vector<std::string> TemplateArgs; @@ -1227,9 +1231,12 @@ class Record { std::vector<Record*> SuperClasses; public: - explicit Record(const std::string &N, SMLoc loc) : Name(N), Loc(loc) {} + explicit Record(const std::string &N, SMLoc loc) : + ID(LastID++), Name(N), Loc(loc) {} ~Record() {} + unsigned getID() const { return ID; } + const std::string &getName() const { return Name; } void setName(const std::string &Name); // Also updates RecordKeeper. |