diff --git a/include/glow/Support/Register.h b/include/glow/Support/Register.h index 402ede10e5..e880c7e2fa 100644 --- a/include/glow/Support/Register.h +++ b/include/glow/Support/Register.h @@ -62,7 +62,7 @@ template class FactoryRegistry { return it->second->create(); } -private: + /// \returns all registered factories. static FactoryMap &factories() { static FactoryMap *factories = new FactoryMap(); return *factories; diff --git a/lib/Backends/Backends.cpp b/lib/Backends/Backends.cpp index 8b06861628..4c8aae9fb9 100644 --- a/lib/Backends/Backends.cpp +++ b/lib/Backends/Backends.cpp @@ -25,6 +25,14 @@ Backend *createBackend(BackendKind backendKind) { Backend *createBackend(llvm::StringRef backendName) { auto *backend = FactoryRegistry::get(backendName); + + if (backend == nullptr) { + LOG(INFO) << "List of all registered backends:"; + for (const auto &factory : + FactoryRegistry::factories()) { + LOG(INFO) << factory.first; + } + } CHECK(backend) << strFormat("Cannot find registered backend: %s", backendName.data()); return backend;