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

Side by Side Diff: lib/Bitcode/NaCl/Reader/NaClBitcodeReader.cpp

Issue 23753003: Report fatal translator errors to the browser (Closed) Base URL: http://git.chromium.org/native_client/pnacl-llvm.git@master
Patch Set: try again Created 7 years, 3 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 | « no previous file | tools/pnacl-llc/SRPCStreamer.h » ('j') | tools/pnacl-llc/SRPCStreamer.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 //===- NaClBitcodeReader.cpp ----------------------------------------------===// 1 //===- NaClBitcodeReader.cpp ----------------------------------------------===//
2 // Internal NaClBitcodeReader implementation 2 // Internal NaClBitcodeReader implementation
3 // 3 //
4 // The LLVM Compiler Infrastructure 4 // The LLVM Compiler Infrastructure
5 // 5 //
6 // This file is distributed under the University of Illinois Open Source 6 // This file is distributed under the University of Illinois Open Source
7 // License. See LICENSE.TXT for details. 7 // License. See LICENSE.TXT for details.
8 // 8 //
9 //===----------------------------------------------------------------------===// 9 //===----------------------------------------------------------------------===//
10 10
(...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after
979 // PNaCl does not support different DataLayouts in pexes, so we 979 // PNaCl does not support different DataLayouts in pexes, so we
980 // implicitly set the DataLayout to the following default. 980 // implicitly set the DataLayout to the following default.
981 // 981 //
982 // This is not usually needed by the backend, but it might be used 982 // This is not usually needed by the backend, but it might be used
983 // by IR passes that the PNaCl translator runs. We set this in the 983 // by IR passes that the PNaCl translator runs. We set this in the
984 // reader rather than in pnacl-llc so that 'opt' will also use the 984 // reader rather than in pnacl-llc so that 'opt' will also use the
985 // correct DataLayout if it is run on a pexe. 985 // correct DataLayout if it is run on a pexe.
986 M->setDataLayout("e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-" 986 M->setDataLayout("e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-"
987 "f32:32:32-f64:64:64-p:32:32:32-v128:32:32"); 987 "f32:32:32-f64:64:64-p:32:32:32-v128:32:32");
988 988
989 if (InitStream()) return Error(Header.Unsupported()); 989 if (InitStream()) return true; // InitSream will set the error string.
990 990
991 // We expect a number of well-defined blocks, though we don't necessarily 991 // We expect a number of well-defined blocks, though we don't necessarily
992 // need to understand them all. 992 // need to understand them all.
993 while (1) { 993 while (1) {
994 if (Stream.AtEndOfStream()) 994 if (Stream.AtEndOfStream())
995 return false; 995 return false;
996 996
997 NaClBitstreamEntry Entry = 997 NaClBitstreamEntry Entry =
998 Stream.advance(NaClBitstreamCursor::AF_DontAutoprocessAbbrevs); 998 Stream.advance(NaClBitstreamCursor::AF_DontAutoprocessAbbrevs);
999 999
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
1751 1751
1752 if (Buffer->getBufferSize() & 3) 1752 if (Buffer->getBufferSize() & 3)
1753 return Error("Bitcode stream should be a multiple of 4 bytes in length"); 1753 return Error("Bitcode stream should be a multiple of 4 bytes in length");
1754 1754
1755 if (Header.Read(BufPtr, BufEnd)) 1755 if (Header.Read(BufPtr, BufEnd))
1756 return Error("Invalid PNaCl bitcode header"); 1756 return Error("Invalid PNaCl bitcode header");
1757 1757
1758 StreamFile.reset(new NaClBitstreamReader(BufPtr, BufEnd)); 1758 StreamFile.reset(new NaClBitstreamReader(BufPtr, BufEnd));
1759 Stream.init(*StreamFile); 1759 Stream.init(*StreamFile);
1760 1760
1761 return AcceptHeader(); 1761 if (AcceptHeader())
jvoung (off chromium) 2013/09/09 23:47:53 Not quite sure the difference in when "return Erro
Derek Schuff 2013/09/10 18:40:23 Error just sets a field that will be read later. B
1762 return Error(Header.Unsupported());
1762 } 1763 }
1763 1764
1764 bool NaClBitcodeReader::InitLazyStream() { 1765 bool NaClBitcodeReader::InitLazyStream() {
1765 StreamingMemoryObject *Bytes = new StreamingMemoryObject(LazyStreamer); 1766 StreamingMemoryObject *Bytes = new StreamingMemoryObject(LazyStreamer);
1766 if (Header.Read(Bytes)) 1767 if (Header.Read(Bytes))
1767 return Error("Invalid PNaCl bitcode header"); 1768 return Error("Invalid PNaCl bitcode header");
1768 1769
1769 StreamFile.reset(new NaClBitstreamReader(Bytes, Header.getHeaderSize())); 1770 StreamFile.reset(new NaClBitstreamReader(Bytes, Header.getHeaderSize()));
1770 Stream.init(*StreamFile); 1771 Stream.init(*StreamFile);
1771 return AcceptHeader(); 1772 if (AcceptHeader())
1773 return Error(Header.Unsupported());
1772 } 1774 }
1773 1775
1774 //===----------------------------------------------------------------------===// 1776 //===----------------------------------------------------------------------===//
1775 // External interface 1777 // External interface
1776 //===----------------------------------------------------------------------===// 1778 //===----------------------------------------------------------------------===//
1777 1779
1778 /// getNaClLazyBitcodeModule - lazy function-at-a-time loading from a file. 1780 /// getNaClLazyBitcodeModule - lazy function-at-a-time loading from a file.
1779 /// 1781 ///
1780 Module *llvm::getNaClLazyBitcodeModule(MemoryBuffer *Buffer, 1782 Module *llvm::getNaClLazyBitcodeModule(MemoryBuffer *Buffer,
1781 LLVMContext& Context, 1783 LLVMContext& Context,
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1836 if (M->MaterializeAllPermanently(ErrMsg)) { 1838 if (M->MaterializeAllPermanently(ErrMsg)) {
1837 delete M; 1839 delete M;
1838 return 0; 1840 return 0;
1839 } 1841 }
1840 1842
1841 // TODO: Restore the use-lists to the in-memory state when the bitcode was 1843 // TODO: Restore the use-lists to the in-memory state when the bitcode was
1842 // written. We must defer until the Module has been fully materialized. 1844 // written. We must defer until the Module has been fully materialized.
1843 1845
1844 return M; 1846 return M;
1845 } 1847 }
OLDNEW
« no previous file with comments | « no previous file | tools/pnacl-llc/SRPCStreamer.h » ('j') | tools/pnacl-llc/SRPCStreamer.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698