[llvm] r333363 - [Tablegen] Avoid generating empty switch statements. NFC
Aaron Ballman via llvm-commits
llvm-commits at lists.llvm.org
Sun May 27 12:16:07 PDT 2018
On Sun, May 27, 2018 at 3:08 PM, Andrea Di Biagio via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> 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.
Thank you!
~Aaron
>
> 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) {
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list