diff --git a/llvm/tools/llc/llc.cpp b/llvm/tools/llc/llc.cpp index 74d39991f6d5..dcd54c18401d 100644 --- a/llvm/tools/llc/llc.cpp +++ b/llvm/tools/llc/llc.cpp @@ -617,7 +617,11 @@ static int compileModule(char **argv, SmallVectorImpl &PluginList, // to avoid a memory leak. Target = std::unique_ptr(TheTarget->createTargetMachine( TheTriple, SkipModuleCPU, FeaturesStr, Options, RM, CM, OLvl)); - assert(Target && "Could not allocate target machine!"); + if (!Target) { + WithColor::error(errs(), argv[0]) + << "could not allocate target machine\n"; + return 1; + } // 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 @@ -646,7 +650,11 @@ static int compileModule(char **argv, SmallVectorImpl &PluginList, InitializeOptions(TheTriple); Target = std::unique_ptr(TheTarget->createTargetMachine( TheTriple, CPUStr, FeaturesStr, Options, RM, CM, OLvl)); - assert(Target && "Could not allocate target machine!"); + if (!Target) { + WithColor::error(errs(), argv[0]) + << "could not allocate target machine\n"; + exit(1); + } // Set PGO options based on command line flags setPGOOptions(*Target);