[llvm-commits] [llvm] r79846 - in /llvm/trunk/utils/TableGen: CodeGenDAGPatterns.cpp CodeGenDAGPatterns.h Record.cpp Record.h

Chris Lattner clattner at apple.com
Sun Aug 23 11:26:45 PDT 2009


On Aug 23, 2009, at 2:54 AM, Daniel Dunbar wrote:

> This may be worth taking for 2.6, it should be an independent and
> "safe" change. Chris, Dan, what do you think?

I'm fine with it, I'll ask Tanya to pull it in.

> - Daniel
>
> On Sun, Aug 23, 2009 at 2:47 AM, Daniel Dunbar<daniel at zuster.org>  
> wrote:
>> Author: ddunbar
>> Date: Sun Aug 23 04:47:37 2009
>> New Revision: 79846
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=79846&view=rev
>> Log:
>> 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.
>>
>> Yay:
>> --
>> ddunbar at giles:~$ cat ~/llvm.obj.64/lib/Target/*/*.inc | shasum
>> d1099ff34b21459a5a3e7021c225c080e6017ece  -
>> ddunbar at giles:~$ cat ~/llvm.obj.ppc/lib/Target/*/*.inc | shasum
>> d1099ff34b21459a5a3e7021c225c080e6017ece  -
>> --
>>
>> Modified:
>>    llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
>>    llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h
>>    llvm/trunk/utils/TableGen/Record.cpp
>>    llvm/trunk/utils/TableGen/Record.h
>>
>> Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=79846&r1=79845&r2=79846&view=diff
>>
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)
>> +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Sun Aug 23  
>> 04:47:37 2009
>> @@ -100,6 +100,9 @@
>>  } // 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;
>>
>> Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h?rev=79846&r1=79845&r2=79846&view=diff
>>
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h (original)
>> +++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h Sun Aug 23  
>> 04:47:37 2009
>> @@ -462,6 +462,10 @@
>>   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 @@
>>   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;
>>
>> Modified: llvm/trunk/utils/TableGen/Record.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.cpp?rev=79846&r1=79845&r2=79846&view=diff
>>
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- llvm/trunk/utils/TableGen/Record.cpp (original)
>> +++ llvm/trunk/utils/TableGen/Record.cpp Sun Aug 23 04:47:37 2009
>> @@ -1319,6 +1319,8 @@
>>   if (PrintSem) OS << ";\n";
>>  }
>>
>> +unsigned Record::LastID = 0;
>> +
>>  void Record::setName(const std::string &Name) {
>>   if (Records.getDef(getName()) == this) {
>>     Records.removeDef(getName());
>>
>> Modified: llvm/trunk/utils/TableGen/Record.h
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/Record.h?rev=79846&r1=79845&r2=79846&view=diff
>>
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> = 
>> =====================================================================
>> --- llvm/trunk/utils/TableGen/Record.h (original)
>> +++ llvm/trunk/utils/TableGen/Record.h Sun Aug 23 04:47:37 2009
>> @@ -1220,6 +1220,10 @@
>>  }
>>
>>  class Record {
>> +  static unsigned LastID;
>> +
>> +  // Unique record ID.
>> +  unsigned ID;
>>   std::string Name;
>>   SMLoc Loc;
>>   std::vector<std::string> TemplateArgs;
>> @@ -1227,9 +1231,12 @@
>>   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.
>>
>>
>>
>> _______________________________________________
>> llvm-commits mailing list
>> llvm-commits at cs.uiuc.edu
>> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list