[llvm] r333363 - [Tablegen] Avoid generating empty switch statements. NFC
Andrea Di Biagio via llvm-commits
llvm-commits at lists.llvm.org
Sun May 27 12:08:13 PDT 2018
Author: adibiagio
Date: Sun May 27 12:08:12 2018
New Revision: 333363
URL: http://llvm.org/viewvc/llvm-project?rev=333363&view=rev
Log:
[Tablegen] Avoid generating empty switch statements. NFC
This fixes an MSVC warning (warning C4065: switch statement contains 'default'
but no 'case' labels) introduced with revision 333293.
Modified:
llvm/trunk/utils/TableGen/SubtargetEmitter.cpp
Modified: llvm/trunk/utils/TableGen/SubtargetEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/SubtargetEmitter.cpp?rev=333363&r1=333362&r2=333363&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/SubtargetEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/SubtargetEmitter.cpp Sun May 27 12:08:12 2018
@@ -1506,7 +1506,7 @@ void SubtargetEmitter::emitSchedModelHel
}
if (!VariantClasses.empty()) {
- OS << " switch (SchedClass) {\n";
+ bool FoundPredicates = false;
for (unsigned VC : VariantClasses) {
// Emit code for each variant scheduling class.
const CodeGenSchedClass &SC = SchedModels.getSchedClass(VC);
@@ -1527,6 +1527,12 @@ void SubtargetEmitter::emitSchedModelHel
if (ProcIndices.empty())
continue;
+ // Emit a switch statement only if there are predicates to expand.
+ if (!FoundPredicates) {
+ OS << " switch (SchedClass) {\n";
+ FoundPredicates = true;
+ }
+
OS << " case " << VC << ": // " << SC.Name << '\n';
PredicateExpander PE;
PE.setByRef(false);
@@ -1556,9 +1562,9 @@ void SubtargetEmitter::emitSchedModelHel
OS << " return " << SC.Index << ";\n";
OS << " break;\n";
}
- // Add a default case to avoid generating a potentially empty switch.
- OS << " default : break;\n"
- << " };\n";
+
+ if (FoundPredicates)
+ OS << " };\n";
}
if (OnlyExpandMCInstPredicates) {
More information about the llvm-commits
mailing list