Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(22)

Side by Side Diff: src/IceCompileServer.cpp

Issue 1961743002: Subzero: Update for LLVM 3.9 (trunk). (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-subzero@master
Patch Set: Remove unnecessary variable Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/IceClFlags.cpp ('k') | src/IceCompiler.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 namespace Ice { 43 namespace Ice {
44 44
45 namespace { 45 namespace {
46 46
47 // Define a SmallVector backed buffer as a data stream, so that it can hold the 47 // Define a SmallVector backed buffer as a data stream, so that it can hold the
48 // generated binary version of the textual bitcode in the input file. 48 // generated binary version of the textual bitcode in the input file.
49 class TextDataStreamer : public llvm::DataStreamer { 49 class TextDataStreamer : public llvm::DataStreamer {
50 public: 50 public:
51 TextDataStreamer() = default; 51 TextDataStreamer() = default;
52 ~TextDataStreamer() final = default; 52 ~TextDataStreamer() final = default;
53 static TextDataStreamer *create(const std::string &Filename, 53 #ifdef PNACL_LLVM
54 std::string *Err); 54 using CreateType = TextDataStreamer *;
55 #else // !PNACL_LLVM
56 using CreateType = std::unique_ptr<TextDataStreamer>;
57 #endif // !PNACL_LLVM
58 static CreateType create(const std::string &Filename, std::string *Err);
55 size_t GetBytes(unsigned char *Buf, size_t Len) final; 59 size_t GetBytes(unsigned char *Buf, size_t Len) final;
56 60
57 private: 61 private:
58 llvm::SmallVector<char, 1024> BitcodeBuffer; 62 llvm::SmallVector<char, 1024> BitcodeBuffer;
59 size_t Cursor = 0; 63 size_t Cursor = 0;
60 }; 64 };
61 65
62 TextDataStreamer *TextDataStreamer::create(const std::string &Filename, 66 TextDataStreamer::CreateType
63 std::string *Err) { 67 TextDataStreamer::create(const std::string &Filename, std::string *Err) {
68 #ifdef PNACL_LLVM
64 TextDataStreamer *Streamer = new TextDataStreamer(); 69 TextDataStreamer *Streamer = new TextDataStreamer();
65 llvm::raw_string_ostream ErrStrm(*Err); 70 llvm::raw_string_ostream ErrStrm(*Err);
66 if (std::error_code EC = llvm::readNaClRecordTextAndBuildBitcode( 71 if (std::error_code EC = llvm::readNaClRecordTextAndBuildBitcode(
67 Filename, Streamer->BitcodeBuffer, &ErrStrm)) { 72 Filename, Streamer->BitcodeBuffer, &ErrStrm)) {
68 ErrStrm << EC.message(); 73 ErrStrm << EC.message();
69 ErrStrm.flush(); 74 ErrStrm.flush();
70 delete Streamer; 75 delete Streamer;
71 return nullptr; 76 return nullptr;
72 } 77 }
73 ErrStrm.flush(); 78 ErrStrm.flush();
74 return Streamer; 79 return Streamer;
80 #else // !PNACL_LLVM
81 return CreateType();
82 #endif // !PNACL_LLVM
75 } 83 }
76 84
77 size_t TextDataStreamer::GetBytes(unsigned char *Buf, size_t Len) { 85 size_t TextDataStreamer::GetBytes(unsigned char *Buf, size_t Len) {
78 if (Cursor >= BitcodeBuffer.size()) 86 if (Cursor >= BitcodeBuffer.size())
79 return 0; 87 return 0;
80 size_t Remaining = BitcodeBuffer.size(); 88 size_t Remaining = BitcodeBuffer.size();
81 Len = std::min(Len, Remaining); 89 Len = std::min(Len, Remaining);
82 for (size_t i = 0; i < Len; ++i) 90 for (size_t i = 0; i < Len; ++i)
83 Buf[i] = BitcodeBuffer[Cursor + i]; 91 Buf[i] = BitcodeBuffer[Cursor + i];
84 Cursor += Len; 92 Cursor += Len;
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 } else { 248 } else {
241 getCompiler().run(Flags, *Ctx.get(), std::move(InputStream)); 249 getCompiler().run(Flags, *Ctx.get(), std::move(InputStream));
242 } 250 }
243 transferErrorCode( 251 transferErrorCode(
244 getReturnValue(static_cast<ErrorCodes>(Ctx->getErrorStatus()->value()))); 252 getReturnValue(static_cast<ErrorCodes>(Ctx->getErrorStatus()->value())));
245 Ctx->dumpConstantLookupCounts(); 253 Ctx->dumpConstantLookupCounts();
246 Ctx->dumpStrings(); 254 Ctx->dumpStrings();
247 } 255 }
248 256
249 } // end of namespace Ice 257 } // end of namespace Ice
OLDNEW
« no previous file with comments | « src/IceClFlags.cpp ('k') | src/IceCompiler.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698