OLD | NEW |
1 //===- subzero/src/IceCompileServer.cpp - Compile server ------------------===// | 1 //===- subzero/src/IceCompileServer.cpp - Compile server ------------------===// |
2 // | 2 // |
3 // The Subzero Code Generator | 3 // The Subzero Code Generator |
4 // | 4 // |
5 // This file is distributed under the University of Illinois Open Source | 5 // This file is distributed under the University of Illinois Open Source |
6 // License. See LICENSE.TXT for details. | 6 // License. See LICENSE.TXT for details. |
7 // | 7 // |
8 //===----------------------------------------------------------------------===// | 8 //===----------------------------------------------------------------------===// |
9 /// | 9 /// |
10 /// \file | 10 /// \file |
11 /// \brief Defines the basic commandline-based compile server. | 11 /// \brief Defines the basic commandline-based compile server. |
12 /// | 12 /// |
13 //===----------------------------------------------------------------------===// | 13 //===----------------------------------------------------------------------===// |
14 | 14 |
15 #include "IceCompileServer.h" | 15 #include "IceCompileServer.h" |
16 | 16 |
17 #include "IceClFlags.h" | 17 #include "IceClFlags.h" |
18 #include "IceClFlagsExtra.h" | 18 #include "IceClFlagsExtra.h" |
19 #include "IceELFStreamer.h" | 19 #include "IceELFStreamer.h" |
20 #include "IceGlobalContext.h" | 20 #include "IceGlobalContext.h" |
| 21 #include "LinuxMallocProfiling.h" |
21 | 22 |
22 #ifdef __clang__ | 23 #ifdef __clang__ |
23 #pragma clang diagnostic push | 24 #pragma clang diagnostic push |
24 #pragma clang diagnostic ignored "-Wunused-parameter" | 25 #pragma clang diagnostic ignored "-Wunused-parameter" |
25 #endif // __clang__ | 26 #endif // __clang__ |
26 | 27 |
27 #include "llvm/Bitcode/NaCl/NaClBitcodeMungeUtils.h" | 28 #include "llvm/Bitcode/NaCl/NaClBitcodeMungeUtils.h" |
28 #include "llvm/Support/FileSystem.h" | 29 #include "llvm/Support/FileSystem.h" |
29 #include "llvm/Support/raw_os_ostream.h" | 30 #include "llvm/Support/raw_os_ostream.h" |
30 #include "llvm/Support/Signals.h" | 31 #include "llvm/Support/Signals.h" |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
166 // Override report_fatal_error if we want to exit with 0 status. | 167 // Override report_fatal_error if we want to exit with 0 status. |
167 if (ExtraFlags.getAlwaysExitSuccess()) | 168 if (ExtraFlags.getAlwaysExitSuccess()) |
168 llvm::install_fatal_error_handler(reportFatalErrorThenExitSuccess, this); | 169 llvm::install_fatal_error_handler(reportFatalErrorThenExitSuccess, this); |
169 | 170 |
170 std::error_code EC; | 171 std::error_code EC; |
171 std::unique_ptr<Ostream> Ls = makeStream(ExtraFlags.getLogFilename(), EC); | 172 std::unique_ptr<Ostream> Ls = makeStream(ExtraFlags.getLogFilename(), EC); |
172 if (EC) { | 173 if (EC) { |
173 llvm::report_fatal_error("Unable to open log file"); | 174 llvm::report_fatal_error("Unable to open log file"); |
174 } | 175 } |
175 Ls->SetUnbuffered(); | 176 Ls->SetUnbuffered(); |
| 177 Ice::LinuxMallocProfiling _(Flags.getNumTranslationThreads(), Ls.get()); |
| 178 |
176 std::unique_ptr<Ostream> Os; | 179 std::unique_ptr<Ostream> Os; |
177 std::unique_ptr<ELFStreamer> ELFStr; | 180 std::unique_ptr<ELFStreamer> ELFStr; |
178 switch (Flags.getOutFileType()) { | 181 switch (Flags.getOutFileType()) { |
179 case FT_Elf: { | 182 case FT_Elf: { |
180 if (ExtraFlags.getOutputFilename() == "-") { | 183 if (ExtraFlags.getOutputFilename() == "-") { |
181 *Ls << "Error: writing binary ELF to stdout is unsupported\n"; | 184 *Ls << "Error: writing binary ELF to stdout is unsupported\n"; |
182 return transferErrorCode(getReturnValue(Ice::EC_Args)); | 185 return transferErrorCode(getReturnValue(Ice::EC_Args)); |
183 } | 186 } |
184 std::unique_ptr<llvm::raw_fd_ostream> FdOs(new llvm::raw_fd_ostream( | 187 std::unique_ptr<llvm::raw_fd_ostream> FdOs(new llvm::raw_fd_ostream( |
185 ExtraFlags.getOutputFilename(), EC, llvm::sys::fs::F_None)); | 188 ExtraFlags.getOutputFilename(), EC, llvm::sys::fs::F_None)); |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
236 CompileThread.join(); | 239 CompileThread.join(); |
237 } else { | 240 } else { |
238 getCompiler().run(ExtraFlags, *Ctx.get(), std::move(InputStream)); | 241 getCompiler().run(ExtraFlags, *Ctx.get(), std::move(InputStream)); |
239 } | 242 } |
240 transferErrorCode( | 243 transferErrorCode( |
241 getReturnValue(static_cast<ErrorCodes>(Ctx->getErrorStatus()->value()))); | 244 getReturnValue(static_cast<ErrorCodes>(Ctx->getErrorStatus()->value()))); |
242 Ctx->dumpConstantLookupCounts(); | 245 Ctx->dumpConstantLookupCounts(); |
243 } | 246 } |
244 | 247 |
245 } // end of namespace Ice | 248 } // end of namespace Ice |
OLD | NEW |