Do not let getLegalValueTypes return a list with duplicates in it
authorChris Lattner <sabre@nondot.org>
Fri, 14 Oct 2005 03:54:49 +0000 (03:54 +0000)
committerChris Lattner <sabre@nondot.org>
Fri, 14 Oct 2005 03:54:49 +0000 (03:54 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23723 91177308-0d34-0410-b5e6-96231b3b80d8

utils/TableGen/CodeGenTarget.cpp

index f0fdeae94566ac55da941a1cd44dca2f36b3b9b4..1b3605a273c06300ee911807165f78911de008bb 100644 (file)
@@ -19,6 +19,7 @@
 #include "llvm/ADT/StringExtras.h"
 #include "llvm/Support/CommandLine.h"
 #include <set>
+#include <algorithm>
 using namespace llvm;
 
 static cl::opt<unsigned>
@@ -179,6 +180,12 @@ void CodeGenTarget::ReadLegalValueTypes() const {
   const std::vector<CodeGenRegisterClass> &RCs = getRegisterClasses();
   for (unsigned i = 0, e = RCs.size(); i != e; ++i)
     LegalValueTypes.push_back(RCs[i].VT);
+  
+  // Remove duplicates.
+  std::sort(LegalValueTypes.begin(), LegalValueTypes.end());
+  LegalValueTypes.erase(std::unique(LegalValueTypes.begin(),
+                                    LegalValueTypes.end()),
+                        LegalValueTypes.end());
 }