[llvm] r235824 - Make the message associated with a fatal error slightly more helpful

Philip Reames listmail at philipreames.com
Sun Apr 26 15:00:35 PDT 2015


Author: reames
Date: Sun Apr 26 17:00:34 2015
New Revision: 235824

URL: http://llvm.org/viewvc/llvm-project?rev=235824&view=rev
Log:
Make the message associated with a fatal error slightly more helpful

Looking into 23095, my best guess is that the CodeGen library itself isn't getting linked and initialized properly.  To make this slightly more obvious to consumers of LLVM, emit a different error message if we can tell that the registry is empty vs you've simply happened to name a collector which hasn't been registered.  


Modified:
    llvm/trunk/lib/CodeGen/GCMetadata.cpp

Modified: llvm/trunk/lib/CodeGen/GCMetadata.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/GCMetadata.cpp?rev=235824&r1=235823&r2=235824&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/GCMetadata.cpp (original)
+++ llvm/trunk/lib/CodeGen/GCMetadata.cpp Sun Apr 26 17:00:34 2015
@@ -148,7 +148,6 @@ bool Printer::doFinalization(Module &M)
   return false;
 }
 
-
 GCStrategy *GCModuleInfo::getGCStrategy(const StringRef Name) {
   // TODO: Arguably, just doing a linear search would be faster for small N
   auto NMI = GCStrategyMap.find(Name);
@@ -165,5 +164,14 @@ GCStrategy *GCModuleInfo::getGCStrategy(
     }
   }
 
-  report_fatal_error(std::string("unsupported GC: ") + Name);
+  if (GCRegistry::begin() == GCRegistry::end()) {
+    // In normal operation, the registry should not be empty.  There should 
+    // be the builtin GCs if nothing else.  The most likely scenario here is
+    // that we got here without running the initializers used by the Registry 
+    // itself and it's registration mechanism.
+    const std::string error = ("unsupported GC: " + Name).str() + 
+      " (did you remember to link and initialize the CodeGen library?)";
+    report_fatal_error(error);
+  } else
+    report_fatal_error(std::string("unsupported GC: ") + Name);
 }





More information about the llvm-commits mailing list