Index: src/IceCompiler.cpp |
diff --git a/src/IceCompiler.cpp b/src/IceCompiler.cpp |
index 2d70b6641800227e2f50b47b5543e2973d4f5dfa..2d22782f8ce4ed80aba3b739b97eeab8306e0d06 100644 |
--- a/src/IceCompiler.cpp |
+++ b/src/IceCompiler.cpp |
@@ -17,6 +17,8 @@ |
/// |
//===----------------------------------------------------------------------===// |
+#include <regex> |
Jim Stichnoth
2015/12/23 15:54:15
Our (unwritten) convention is to put system includ
Jim Stichnoth
2015/12/25 15:31:01
This still needs to be done.
rkotlerimgtec
2015/12/26 23:29:42
Done.
|
+ |
#include "IceCompiler.h" |
#include "IceBuildDefs.h" |
@@ -89,11 +91,11 @@ void validateAndGenerateBuildAttributes(Ostream *Stream) { |
void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx, |
std::unique_ptr<llvm::DataStreamer> &&InputStream) { |
- validateAndGenerateBuildAttributes( |
- ExtraFlags.getGenerateBuildAtts() ? &Ctx.getStrDump() : nullptr); |
- if (ExtraFlags.getGenerateBuildAtts()) |
- return Ctx.getErrorStatus()->assign(EC_None); |
- |
+ if (ExtraFlags.getGenerateBuildAtts()) { |
+ validateAndGenerateBuildAttributes(&Ctx.getStrDump()); |
+ Ctx.getErrorStatus()->assign(EC_None); |
+ return; |
+ } |
// The Minimal build (specifically, when dump()/emit() are not implemented) |
// allows only --filetype=obj. Check here to avoid cryptic error messages |
// downstream. |
@@ -102,25 +104,20 @@ void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx, |
// llvm::Option.ArgStr and .ValueStr . |
Ctx.getStrError() |
<< "Error: only --filetype=obj is supported in this build.\n"; |
- return Ctx.getErrorStatus()->assign(EC_Args); |
+ Ctx.getErrorStatus()->assign(EC_Args); |
+ return; |
} |
- // Force -build-on-read=0 for .ll files. |
- const std::string LLSuffix = ".ll"; |
- const IceString &IRFilename = ExtraFlags.getIRFilename(); |
- bool BuildOnRead = ExtraFlags.getBuildOnRead(); |
- if (BuildDefs::llvmIrAsInput() && IRFilename.length() >= LLSuffix.length() && |
- IRFilename.compare(IRFilename.length() - LLSuffix.length(), |
- LLSuffix.length(), LLSuffix) == 0) |
- BuildOnRead = false; |
- |
TimerMarker T(Ice::TimerStack::TT_szmain, &Ctx); |
Ctx.emitFileHeader(); |
Ctx.startWorkerThreads(); |
std::unique_ptr<Translator> Translator; |
- if (BuildOnRead) { |
+ const IceString &IRFilename = ExtraFlags.getIRFilename(); |
+ // Force -build-on-read=0 for .ll files. |
+ if (!std::regex_match(IRFilename, std::regex(".*\\.ll")) && |
+ ExtraFlags.getBuildOnRead()) { |
std::unique_ptr<PNaClTranslator> PTranslator(new PNaClTranslator(&Ctx)); |
std::unique_ptr<llvm::StreamingMemoryObject> MemObj( |
new llvm::StreamingMemoryObjectImpl(InputStream.release())); |
@@ -130,7 +127,8 @@ void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx, |
if (BuildDefs::browser()) { |
Ctx.getStrError() |
<< "non BuildOnRead is not supported w/ PNACL_BROWSER_TRANSLATOR\n"; |
- return Ctx.getErrorStatus()->assign(EC_Args); |
+ Ctx.getErrorStatus()->assign(EC_Args); |
+ return; |
} |
// Parse the input LLVM IR file into a module. |
llvm::SMDiagnostic Err; |
@@ -144,7 +142,8 @@ void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx, |
llvm::getGlobalContext(), DiagnosticHandler); |
if (!Mod) { |
Err.print(ExtraFlags.getAppName().c_str(), llvm::errs()); |
- return Ctx.getErrorStatus()->assign(EC_Bitcode); |
+ Ctx.getErrorStatus()->assign(EC_Bitcode); |
+ return; |
} |
std::unique_ptr<Converter> Converter(new class Converter(Mod.get(), &Ctx)); |
@@ -153,7 +152,8 @@ void Compiler::run(const Ice::ClFlagsExtra &ExtraFlags, GlobalContext &Ctx, |
} else { |
Ctx.getStrError() << "Error: Build doesn't allow LLVM IR, " |
<< "--build-on-read=0 not allowed\n"; |
- return Ctx.getErrorStatus()->assign(EC_Args); |
+ Ctx.getErrorStatus()->assign(EC_Args); |
+ return; |
} |
Ctx.waitForWorkerThreads(); |