[llvm] r208102 - Have the SubtargetFeature help routine just not return a number and

Eric Christopher echristo at gmail.com
Tue May 6 09:29:50 PDT 2014


Author: echristo
Date: Tue May  6 11:29:50 2014
New Revision: 208102

URL: http://llvm.org/viewvc/llvm-project?rev=208102&view=rev
Log:
Have the SubtargetFeature help routine just not return a number and
fall back to the normal path without a cpu. While doing this fix
llc to just exit when we don't have a module to process instead of
asserting.

Modified:
    llvm/trunk/lib/MC/SubtargetFeature.cpp
    llvm/trunk/tools/llc/llc.cpp

Modified: llvm/trunk/lib/MC/SubtargetFeature.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/MC/SubtargetFeature.cpp?rev=208102&r1=208101&r2=208102&view=diff
==============================================================================
--- llvm/trunk/lib/MC/SubtargetFeature.cpp (original)
+++ llvm/trunk/lib/MC/SubtargetFeature.cpp Tue May  6 11:29:50 2014
@@ -129,7 +129,7 @@ static size_t getLongestEntryLength(cons
 
 /// Display help for feature choices.
 ///
-static uint64_t Help(const SubtargetFeatureKV *CPUTable, size_t CPUTableSize,
+static void Help(const SubtargetFeatureKV *CPUTable, size_t CPUTableSize,
                      const SubtargetFeatureKV *FeatTable,
                      size_t FeatTableSize) {
   // Determine the length of the longest CPU and Feature entries.
@@ -152,8 +152,6 @@ static uint64_t Help(const SubtargetFeat
 
   errs() << "Use +feature to enable a feature, or -feature to disable it.\n"
             "For example, llc -mcpu=mycpu -mattr=+feature1,-feature2\n";
-
-  return 0;
 }
 
 //===----------------------------------------------------------------------===//
@@ -264,10 +262,10 @@ uint64_t SubtargetFeatures::getFeatureBi
 
   // Check if help is needed
   if (CPU == "help")
-    return Help(CPUTable, CPUTableSize, FeatureTable, FeatureTableSize);
+    Help(CPUTable, CPUTableSize, FeatureTable, FeatureTableSize);
 
   // Find CPU entry if CPU name is specified.
-  if (!CPU.empty()) {
+  else if (!CPU.empty()) {
     const SubtargetFeatureKV *CPUEntry = Find(CPU, CPUTable, CPUTableSize);
     // If there is a match
     if (CPUEntry) {
@@ -293,7 +291,7 @@ uint64_t SubtargetFeatures::getFeatureBi
 
     // Check for help
     if (Feature == "+help")
-      return Help(CPUTable, CPUTableSize, FeatureTable, FeatureTableSize);
+      Help(CPUTable, CPUTableSize, FeatureTable, FeatureTableSize);
 
     // Find feature in table.
     const SubtargetFeatureKV *FeatureEntry =

Modified: llvm/trunk/tools/llc/llc.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llc/llc.cpp?rev=208102&r1=208101&r2=208102&view=diff
==============================================================================
--- llvm/trunk/tools/llc/llc.cpp (original)
+++ llvm/trunk/tools/llc/llc.cpp Tue May  6 11:29:50 2014
@@ -277,7 +277,14 @@ static int compileModule(char **argv, LL
       TheTarget->createTargetMachine(TheTriple.getTriple(), MCPU, FeaturesStr,
                                      Options, RelocModel, CMModel, OLvl));
   assert(target.get() && "Could not allocate target machine!");
-  assert(mod && "Should have exited after outputting help!");
+
+  // If we don't have a module then just exit now. We do this down
+  // here since the CPU/Feature help is underneath the target machine
+  // creation.
+  if (SkipModule)
+    return 0;
+
+  assert(mod && "Should have exited if we didn't have a module!");
   TargetMachine &Target = *target.get();
 
   if (EnableDwarfDirectory)





More information about the llvm-commits mailing list