From 989d94ddde604503b29098e7e9430bfe7baa588a Mon Sep 17 00:00:00 2001 From: Craig Topper Date: Wed, 21 Mar 2018 19:52:13 +0000 Subject: [PATCH] [TableGen] Hoist the code for copying InstRWs from an old scheduling class to a new one out of the loop that assigns instructions to the new class. NFCI We already know all the of instructions we're processing in the instruction loop belong to no class or all to the same class. So we only have to worry about remapping one class. So hoist it all out and remove the SmallPtrSet that tracked which class we'd already remapped. I had to introduce new instruction loop inside this code to print an error message, but that only occurs on the error path. llvm-svn: 328142 --- llvm/utils/TableGen/CodeGenSchedule.cpp | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/llvm/utils/TableGen/CodeGenSchedule.cpp b/llvm/utils/TableGen/CodeGenSchedule.cpp index 446a641..a21e44b 100644 --- a/llvm/utils/TableGen/CodeGenSchedule.cpp +++ b/llvm/utils/TableGen/CodeGenSchedule.cpp @@ -800,25 +800,25 @@ void CodeGenSchedModels::createInstRWClass(Record *InstRWDef) { SC.Writes = SchedClasses[OldSCIdx].Writes; SC.Reads = SchedClasses[OldSCIdx].Reads; SC.ProcIndices.push_back(0); - // Map each Instr to this new class. - // Note that InstDefs may be a smaller list than InstRWDef's "Instrs". - Record *RWModelDef = InstRWDef->getValueAsDef("SchedModel"); - SmallSet RemappedClassIDs; - for (Record *InstDef : InstDefs) { - if (OldSCIdx && RemappedClassIDs.insert(OldSCIdx).second) { - for (Record *OldRWDef : SchedClasses[OldSCIdx].InstRWs) { - if (OldRWDef->getValueAsDef("SchedModel") == RWModelDef) { + // If we had an old class, copy it's InstRWs to this new class. + if (OldSCIdx) { + Record *RWModelDef = InstRWDef->getValueAsDef("SchedModel"); + for (Record *OldRWDef : SchedClasses[OldSCIdx].InstRWs) { + if (OldRWDef->getValueAsDef("SchedModel") == RWModelDef) { + for (Record *InstDef : InstDefs) { PrintFatalError(OldRWDef->getLoc(), "Overlapping InstRW def " + InstDef->getName() + " also matches " + OldRWDef->getValue("Instrs")->getValue()->getAsString()); } - assert(OldRWDef != InstRWDef && - "SchedClass has duplicate InstRW def"); - SC.InstRWs.push_back(OldRWDef); } + assert(OldRWDef != InstRWDef && + "SchedClass has duplicate InstRW def"); + SC.InstRWs.push_back(OldRWDef); } - InstrClassMap[InstDef] = SCIdx; } + // Map each Instr to this new class. + for (Record *InstDef : InstDefs) + InstrClassMap[InstDef] = SCIdx; SC.InstRWs.push_back(InstRWDef); } } -- 2.7.4