[llvm] r375071 - Correct placement of #ifndef NDEBUG in r375067

Daniel Sanders via llvm-commits llvm-commits at lists.llvm.org
Wed Oct 16 18:21:53 PDT 2019


Author: dsanders
Date: Wed Oct 16 18:21:53 2019
New Revision: 375071

URL: http://llvm.org/viewvc/llvm-project?rev=375071&view=rev
Log:
Correct placement of #ifndef NDEBUG in r375067

Modified:
    llvm/trunk/utils/TableGen/GICombinerEmitter.cpp

Modified: llvm/trunk/utils/TableGen/GICombinerEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/GICombinerEmitter.cpp?rev=375071&r1=375070&r2=375071&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/GICombinerEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/GICombinerEmitter.cpp Wed Oct 16 18:21:53 2019
@@ -228,19 +228,19 @@ void GICombinerEmitter::emitNameMatcher(
     Cases.push_back(std::make_pair(EnumeratedRule.getName(), SS.str()));
   }
 
-  OS << "#ifndef NDEBUG\n"
-     << "static Optional<uint64_t> getRuleIdxForIdentifier(StringRef "
+  OS << "static Optional<uint64_t> getRuleIdxForIdentifier(StringRef "
         "RuleIdentifier) {\n"
      << "  uint64_t I;\n"
      << "  // getAtInteger(...) returns false on success\n"
      << "  bool Parsed = !RuleIdentifier.getAsInteger(0, I);\n"
      << "  if (Parsed)\n"
-     << "    return I;\n\n";
+     << "    return I;\n\n"
+     << "#ifndef NDEBUG\n";
   StringMatcher Matcher("RuleIdentifier", Cases, OS);
   Matcher.Emit();
-  OS << "  return None;\n"
-     << "}\n"
-     << "#endif // ifndef NDEBUG\n\n";
+  OS << "#endif // ifndef NDEBUG\n\n"
+     << "  return None;\n"
+     << "}\n";
 }
 
 std::unique_ptr<CombineRule>
@@ -379,19 +379,14 @@ void GICombinerEmitter::run(raw_ostream
      << "    for (auto I = First.getValue(); I < Last.getValue(); ++I)\n"
      << "      DisabledRules.set(I);\n"
      << "    return true;\n"
-     << "  }\n"
-     << "#ifndef NDEBUG\n"
-     << "  else {\n"
+     << "  } else {\n"
      << "    const auto I = getRuleIdxForIdentifier(RangePair.first);\n"
      << "    if (!I.hasValue())\n"
      << "      return false;\n"
      << "    DisabledRules.set(I.getValue());\n"
      << "    return true;\n"
      << "  }\n"
-     << "#else // ifndef NDEBUG\n"
-     << "  llvm_unreachable(\"Cannot disable rules in non-asserts builds\");\n"
      << "  return false;\n"
-     << "#endif // ifndef NDEBUG\n\n"
      << "}\n";
 
   OS << "bool " << getClassName()




More information about the llvm-commits mailing list