diff options
Diffstat (limited to 'llvm/utils/TableGen/Common/CodeGenRegisters.cpp')
| -rw-r--r-- | llvm/utils/TableGen/Common/CodeGenRegisters.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/llvm/utils/TableGen/Common/CodeGenRegisters.cpp b/llvm/utils/TableGen/Common/CodeGenRegisters.cpp index 3c868b1e8f4f..b5a6c1395c60 100644 --- a/llvm/utils/TableGen/Common/CodeGenRegisters.cpp +++ b/llvm/utils/TableGen/Common/CodeGenRegisters.cpp @@ -22,6 +22,7 @@ #include "llvm/ADT/SmallSet.h" #include "llvm/ADT/SmallVector.h" #include "llvm/ADT/StringRef.h" +#include "llvm/ADT/StringSet.h" #include "llvm/ADT/Twine.h" #include "llvm/Support/Debug.h" #include "llvm/Support/raw_ostream.h" @@ -618,6 +619,9 @@ struct TupleExpander : SetTheory::Expander { // the synthesized definitions for their lifetime. std::vector<std::unique_ptr<Record>> &SynthDefs; + // Track all synthesized tuple names in order to detect duplicate definitions. + llvm::StringSet<> TupleNames; + TupleExpander(std::vector<std::unique_ptr<Record>> &SynthDefs) : SynthDefs(SynthDefs) {} @@ -684,6 +688,12 @@ struct TupleExpander : SetTheory::Expander { Record *NewReg = SynthDefs.back().get(); Elts.insert(NewReg); + // Detect duplicates among synthesized registers. + const auto Res = TupleNames.insert(NewReg->getName()); + if (!Res.second) + PrintFatalError(Def->getLoc(), + "Register tuple redefines register '" + Name + "'."); + // Copy Proto super-classes. ArrayRef<std::pair<Record *, SMRange>> Supers = Proto->getSuperClasses(); for (const auto &SuperPair : Supers) |
