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

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

Issue 1122423005: Add (unsupported experimental) feature allowing byte aligned bitcode. (Closed) Base URL: https://chromium.googlesource.com/native_client/pnacl-llvm.git@master
Patch Set: Fix issues in patch 2. Created 5 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
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 1830 matching lines...) Expand 10 before | Expand all | Expand 10 after
1841 const unsigned char *BufEnd = BufPtr+Buffer->getBufferSize(); 1841 const unsigned char *BufEnd = BufPtr+Buffer->getBufferSize();
1842 1842
1843 if (Buffer->getBufferSize() & 3) 1843 if (Buffer->getBufferSize() & 3)
1844 return Error(InvalidBitstream, 1844 return Error(InvalidBitstream,
1845 "Bitcode stream should be a multiple of 4 bytes in length"); 1845 "Bitcode stream should be a multiple of 4 bytes in length");
1846 1846
1847 const unsigned char *HeaderPtr = BufPtr; 1847 const unsigned char *HeaderPtr = BufPtr;
1848 if (Header.Read(HeaderPtr, BufEnd)) 1848 if (Header.Read(HeaderPtr, BufEnd))
1849 return Error(InvalidBitstream, Header.Unsupported()); 1849 return Error(InvalidBitstream, Header.Unsupported());
1850 1850
1851 StreamFile.reset(new NaClBitstreamReader(BufPtr, BufEnd, 1851 if (AcceptHeader())
1852 Header.getHeaderSize())); 1852 return Error(InvalidBitstream, Header.Unsupported());
1853
1854 StreamFile.reset(new NaClBitstreamReader(
1855 getNonStreamedMemoryObject(BufPtr, BufEnd), Header));
1853 Stream.init(StreamFile.get()); 1856 Stream.init(StreamFile.get());
1854 1857
1855 if (AcceptHeader())
1856 return Error(InvalidBitstream, Header.Unsupported());
1857 return std::error_code(); 1858 return std::error_code();
1858 } 1859 }
1859 1860
1860 std::error_code NaClBitcodeReader::InitLazyStream() { 1861 std::error_code NaClBitcodeReader::InitLazyStream() {
1861 if (Header.Read(LazyStreamer)) 1862 if (Header.Read(LazyStreamer))
1862 return Error(InvalidBitstream, Header.Unsupported()); 1863 return Error(InvalidBitstream, Header.Unsupported());
1863 1864
1864 StreamFile.reset(new NaClBitstreamReader(LazyStreamer,
1865 Header.getHeaderSize()));
1866 Stream.init(StreamFile.get());
1867 if (AcceptHeader()) 1865 if (AcceptHeader())
1868 return Error(InvalidBitstream, Header.Unsupported()); 1866 return Error(InvalidBitstream, Header.Unsupported());
1867
1868 StreamFile.reset(new NaClBitstreamReader(LazyStreamer, Header));
1869 Stream.init(StreamFile.get());
1869 return std::error_code(); 1870 return std::error_code();
1870 } 1871 }
1871 1872
1872 //===----------------------------------------------------------------------===// 1873 //===----------------------------------------------------------------------===//
1873 // External interface 1874 // External interface
1874 //===----------------------------------------------------------------------===// 1875 //===----------------------------------------------------------------------===//
1875 1876
1876 /// \brief Get a lazy one-at-time loading module from bitcode. 1877 /// \brief Get a lazy one-at-time loading module from bitcode.
1877 /// 1878 ///
1878 /// This isn't always used in a lazy context. In particular, it's also used by 1879 /// This isn't always used in a lazy context. In particular, it's also used by
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1935 if (std::error_code EC = M->materializeAllPermanently()) { 1936 if (std::error_code EC = M->materializeAllPermanently()) {
1936 delete M; 1937 delete M;
1937 return EC; 1938 return EC;
1938 } 1939 }
1939 1940
1940 // TODO: Restore the use-lists to the in-memory state when the bitcode was 1941 // TODO: Restore the use-lists to the in-memory state when the bitcode was
1941 // written. We must defer until the Module has been fully materialized. 1942 // written. We must defer until the Module has been fully materialized.
1942 1943
1943 return M; 1944 return M;
1944 } 1945 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698