@@ -65,6 +65,7 @@ STATISTIC(PatternGenNumErrorFormatLoad, "Errors of type: FORMAT_LOAD");
6565STATISTIC (PatternGenNumErrorFormatImm, " Errors of type: FORMAT_IMM" );
6666STATISTIC (PatternGenNumErrorFormat, " Errors of type: FORMAT" );
6767STATISTIC (PatternGenNumErrorMultipleStores, " Errors of type: MULTIPLE STORES" );
68+ STATISTIC (PatternGenNumErrorUnusedOperand, " Errors of type: UNUSED_OPERAND" );
6869
6970#ifdef LLVM_GISEL_COV_PREFIX
7071static cl::opt<std::string>
@@ -142,7 +143,8 @@ enum PatternErrorT {
142143 FORMAT_LOAD,
143144 FORMAT_IMM,
144145 FORMAT,
145- MULTIPLE_STORES
146+ MULTIPLE_STORES,
147+ UNUSED_OPERANDS
146148};
147149struct PatternError {
148150 PatternErrorT Type;
@@ -163,7 +165,8 @@ llvm::Statistic *ErrorStats[] = {nullptr,
163165 &PatternGenNumErrorFormatLoad,
164166 &PatternGenNumErrorFormatImm,
165167 &PatternGenNumErrorFormat,
166- &PatternGenNumErrorMultipleStores};
168+ &PatternGenNumErrorMultipleStores,
169+ &PatternGenNumErrorUnusedOperand};
167170
168171static const std::unordered_map<unsigned , std::string> CmpStr = {
169172 {CmpInst::Predicate::ICMP_EQ, " SETEQ" },
@@ -1366,6 +1369,12 @@ bool PatternGen::runOnMachineFunction(MachineFunction &MF) {
13661369 std::string OutsString;
13671370 std::string InsString;
13681371 for (size_t I = 0 ; I < CurInstr->fields .size () - 1 ; I++) {
1372+ if (!PatternArgs[I].In && !PatternArgs[I].Out ) {
1373+ llvm::errs () << " Pattern Generation failed for " << MF.getName () << " : "
1374+ << " Operand '" << CurInstr->fields [I].ident << " ' not used in pattern!\n " ;
1375+ ++PatternGenNumErrorUnusedOperand;
1376+ return true ;
1377+ }
13691378 if (PatternArgs[I].In ) {
13701379 InsString += PatternArgs[I].ArgTypeStr + " :$" +
13711380 std::string (CurInstr->fields [I].ident ) + " , " ;
0 commit comments