<div dir="ltr">Hi Chris,<div><br></div><div style>This commit broke arm buildbots:</div><div style><br></div><div style><a href="http://lab.llvm.org:8011/builders/clang-native-arm-cortex-a9/builds/4500">http://lab.llvm.org:8011/builders/clang-native-arm-cortex-a9/builds/4500</a><br>
</div><div style><br></div><div style>undefined reference to `llvm::BitstreamCursor::EnterSubBlock(unsigned int, unsigned int*)'<br></div><div style><br></div><div style>but not the Intel ones:</div><div style><br></div>
<div style><a href="http://lab.llvm.org:8011/builders/llvm-x86_64-linux/builds/7378">http://lab.llvm.org:8011/builders/llvm-x86_64-linux/builds/7378</a><br></div><div style><br></div><div style>Could be a CMake issue?</div>
<div style><br></div><div style>cheers,</div><div style>--renato</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On 19 January 2013 18:19, Chris Lattner <span dir="ltr"><<a href="mailto:sabre@nondot.org" target="_blank">sabre@nondot.org</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: lattner<br>
Date: Sat Jan 19 12:19:39 2013<br>
New Revision: 172904<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=172904&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=172904&view=rev</a><br>
Log:<br>
BitstreamReader hasn't aged well. It's been hacked on by various people and<br>
has past the point of making sense. Lets tidy things up: first step, moving<br>
a ton of big functions out of line.<br>
<br>
Added:<br>
llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp<br>
Modified:<br>
llvm/trunk/include/llvm/Bitcode/BitstreamReader.h<br>
llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp<br>
llvm/trunk/lib/Bitcode/Reader/CMakeLists.txt<br>
<br>
Modified: llvm/trunk/include/llvm/Bitcode/BitstreamReader.h<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamReader.h?rev=172904&r1=172903&r2=172904&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Bitcode/BitstreamReader.h?rev=172904&r1=172903&r2=172904&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/include/llvm/Bitcode/BitstreamReader.h (original)<br>
+++ llvm/trunk/include/llvm/Bitcode/BitstreamReader.h Sat Jan 19 12:19:39 2013<br>
@@ -179,50 +179,10 @@<br>
freeState();<br>
}<br>
<br>
- void operator=(const BitstreamCursor &RHS) {<br>
- freeState();<br>
-<br>
- BitStream = RHS.BitStream;<br>
- NextChar = RHS.NextChar;<br>
- CurWord = RHS.CurWord;<br>
- BitsInCurWord = RHS.BitsInCurWord;<br>
- CurCodeSize = RHS.CurCodeSize;<br>
-<br>
- // Copy abbreviations, and bump ref counts.<br>
- CurAbbrevs = RHS.CurAbbrevs;<br>
- for (unsigned i = 0, e = static_cast<unsigned>(CurAbbrevs.size());<br>
- i != e; ++i)<br>
- CurAbbrevs[i]->addRef();<br>
-<br>
- // Copy block scope and bump ref counts.<br>
- BlockScope = RHS.BlockScope;<br>
- for (unsigned S = 0, e = static_cast<unsigned>(BlockScope.size());<br>
- S != e; ++S) {<br>
- std::vector<BitCodeAbbrev*> &Abbrevs = BlockScope[S].PrevAbbrevs;<br>
- for (unsigned i = 0, e = static_cast<unsigned>(Abbrevs.size());<br>
- i != e; ++i)<br>
- Abbrevs[i]->addRef();<br>
- }<br>
- }<br>
-<br>
- void freeState() {<br>
- // Free all the Abbrevs.<br>
- for (unsigned i = 0, e = static_cast<unsigned>(CurAbbrevs.size());<br>
- i != e; ++i)<br>
- CurAbbrevs[i]->dropRef();<br>
- CurAbbrevs.clear();<br>
-<br>
- // Free all the Abbrevs in the block scope.<br>
- for (unsigned S = 0, e = static_cast<unsigned>(BlockScope.size());<br>
- S != e; ++S) {<br>
- std::vector<BitCodeAbbrev*> &Abbrevs = BlockScope[S].PrevAbbrevs;<br>
- for (unsigned i = 0, e = static_cast<unsigned>(Abbrevs.size());<br>
- i != e; ++i)<br>
- Abbrevs[i]->dropRef();<br>
- }<br>
- BlockScope.clear();<br>
- }<br>
+ void operator=(const BitstreamCursor &RHS);<br>
<br>
+ void freeState();<br>
+<br>
/// GetAbbrevIDWidth - Return the number of bits used to encode an abbrev #.<br>
unsigned GetAbbrevIDWidth() const { return CurCodeSize; }<br>
<br>
@@ -243,12 +203,8 @@<br>
}<br>
<br>
uint32_t getWord(size_t pos) {<br>
- uint8_t buf[sizeof(uint32_t)];<br>
- memset(buf, 0xFF, sizeof(buf));<br>
- BitStream->getBitcodeBytes().readBytes(pos,<br>
- sizeof(buf),<br>
- buf,<br>
- NULL);<br>
+ uint8_t buf[4] = { 0xFF, 0xFF, 0xFF, 0xFF };<br>
+ BitStream->getBitcodeBytes().readBytes(pos, sizeof(buf), buf, NULL);<br>
return *reinterpret_cast<support::ulittle32_t *>(buf);<br>
}<br>
<br>
@@ -410,34 +366,8 @@<br>
<br>
/// EnterSubBlock - Having read the ENTER_SUBBLOCK abbrevid, enter<br>
/// the block, and return true if the block has an error.<br>
- bool EnterSubBlock(unsigned BlockID, unsigned *NumWordsP = 0) {<br>
- // Save the current block's state on BlockScope.<br>
- BlockScope.push_back(Block(CurCodeSize));<br>
- BlockScope.back().PrevAbbrevs.swap(CurAbbrevs);<br>
-<br>
- // Add the abbrevs specific to this block to the CurAbbrevs list.<br>
- if (const BitstreamReader::BlockInfo *Info =<br>
- BitStream->getBlockInfo(BlockID)) {<br>
- for (unsigned i = 0, e = static_cast<unsigned>(Info->Abbrevs.size());<br>
- i != e; ++i) {<br>
- CurAbbrevs.push_back(Info->Abbrevs[i]);<br>
- CurAbbrevs.back()->addRef();<br>
- }<br>
- }<br>
-<br>
- // Get the codesize of this block.<br>
- CurCodeSize = ReadVBR(bitc::CodeLenWidth);<br>
- SkipToWord();<br>
- unsigned NumWords = Read(bitc::BlockSizeWidth);<br>
- if (NumWordsP) *NumWordsP = NumWords;<br>
-<br>
- // Validate that this block is sane.<br>
- if (CurCodeSize == 0 || AtEndOfStream())<br>
- return true;<br>
-<br>
- return false;<br>
- }<br>
-<br>
+ bool EnterSubBlock(unsigned BlockID, unsigned *NumWordsP = 0);<br>
+<br>
bool ReadBlockEnd() {<br>
if (BlockScope.empty()) return true;<br>
<br>
@@ -502,70 +432,8 @@<br>
}<br>
<br>
unsigned ReadRecord(unsigned AbbrevID, SmallVectorImpl<uint64_t> &Vals,<br>
- const char **BlobStart = 0, unsigned *BlobLen = 0) {<br>
- if (AbbrevID == bitc::UNABBREV_RECORD) {<br>
- unsigned Code = ReadVBR(6);<br>
- unsigned NumElts = ReadVBR(6);<br>
- for (unsigned i = 0; i != NumElts; ++i)<br>
- Vals.push_back(ReadVBR64(6));<br>
- return Code;<br>
- }<br>
-<br>
- const BitCodeAbbrev *Abbv = getAbbrev(AbbrevID);<br>
-<br>
- for (unsigned i = 0, e = Abbv->getNumOperandInfos(); i != e; ++i) {<br>
- const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i);<br>
- if (Op.isLiteral()) {<br>
- ReadAbbreviatedLiteral(Op, Vals);<br>
- } else if (Op.getEncoding() == BitCodeAbbrevOp::Array) {<br>
- // Array case. Read the number of elements as a vbr6.<br>
- unsigned NumElts = ReadVBR(6);<br>
-<br>
- // Get the element encoding.<br>
- assert(i+2 == e && "array op not second to last?");<br>
- const BitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i);<br>
-<br>
- // Read all the elements.<br>
- for (; NumElts; --NumElts)<br>
- ReadAbbreviatedField(EltEnc, Vals);<br>
- } else if (Op.getEncoding() == BitCodeAbbrevOp::Blob) {<br>
- // Blob case. Read the number of bytes as a vbr6.<br>
- unsigned NumElts = ReadVBR(6);<br>
- SkipToWord(); // 32-bit alignment<br>
-<br>
- // Figure out where the end of this blob will be including tail padding.<br>
- size_t NewEnd = NextChar+((NumElts+3)&~3);<br>
-<br>
- // If this would read off the end of the bitcode file, just set the<br>
- // record to empty and return.<br>
- if (!canSkipToPos(NewEnd)) {<br>
- Vals.append(NumElts, 0);<br>
- NextChar = BitStream->getBitcodeBytes().getExtent();<br>
- break;<br>
- }<br>
-<br>
- // Otherwise, read the number of bytes. If we can return a reference to<br>
- // the data, do so to avoid copying it.<br>
- if (BlobStart) {<br>
- *BlobStart = (const char*)BitStream->getBitcodeBytes().getPointer(<br>
- NextChar, NumElts);<br>
- *BlobLen = NumElts;<br>
- } else {<br>
- for (; NumElts; ++NextChar, --NumElts)<br>
- Vals.push_back(getByte(NextChar));<br>
- }<br>
- // Skip over tail padding.<br>
- NextChar = NewEnd;<br>
- } else {<br>
- ReadAbbreviatedField(Op, Vals);<br>
- }<br>
- }<br>
-<br>
- unsigned Code = (unsigned)Vals[0];<br>
- Vals.erase(Vals.begin());<br>
- return Code;<br>
- }<br>
-<br>
+ const char **BlobStart = 0, unsigned *BlobLen = 0);<br>
+<br>
unsigned ReadRecord(unsigned AbbrevID, SmallVectorImpl<uint64_t> &Vals,<br>
const char *&BlobStart, unsigned &BlobLen) {<br>
return ReadRecord(AbbrevID, Vals, &BlobStart, &BlobLen);<br>
@@ -576,91 +444,9 @@<br>
// Abbrev Processing<br>
//===--------------------------------------------------------------------===//<br>
<br>
- void ReadAbbrevRecord() {<br>
- BitCodeAbbrev *Abbv = new BitCodeAbbrev();<br>
- unsigned NumOpInfo = ReadVBR(5);<br>
- for (unsigned i = 0; i != NumOpInfo; ++i) {<br>
- bool IsLiteral = Read(1) ? true : false;<br>
- if (IsLiteral) {<br>
- Abbv->Add(BitCodeAbbrevOp(ReadVBR64(8)));<br>
- continue;<br>
- }<br>
-<br>
- BitCodeAbbrevOp::Encoding E = (BitCodeAbbrevOp::Encoding)Read(3);<br>
- if (BitCodeAbbrevOp::hasEncodingData(E))<br>
- Abbv->Add(BitCodeAbbrevOp(E, ReadVBR64(5)));<br>
- else<br>
- Abbv->Add(BitCodeAbbrevOp(E));<br>
- }<br>
- CurAbbrevs.push_back(Abbv);<br>
- }<br>
-<br>
-public:<br>
-<br>
- bool ReadBlockInfoBlock() {<br>
- // If this is the second stream to get to the block info block, skip it.<br>
- if (BitStream->hasBlockInfoRecords())<br>
- return SkipBlock();<br>
-<br>
- if (EnterSubBlock(bitc::BLOCKINFO_BLOCK_ID)) return true;<br>
-<br>
- SmallVector<uint64_t, 64> Record;<br>
- BitstreamReader::BlockInfo *CurBlockInfo = 0;<br>
-<br>
- // Read all the records for this module.<br>
- while (1) {<br>
- unsigned Code = ReadCode();<br>
- if (Code == bitc::END_BLOCK)<br>
- return ReadBlockEnd();<br>
- if (Code == bitc::ENTER_SUBBLOCK) {<br>
- ReadSubBlockID();<br>
- if (SkipBlock()) return true;<br>
- continue;<br>
- }<br>
-<br>
- // Read abbrev records, associate them with CurBID.<br>
- if (Code == bitc::DEFINE_ABBREV) {<br>
- if (!CurBlockInfo) return true;<br>
- ReadAbbrevRecord();<br>
-<br>
- // ReadAbbrevRecord installs the abbrev in CurAbbrevs. Move it to the<br>
- // appropriate BlockInfo.<br>
- BitCodeAbbrev *Abbv = CurAbbrevs.back();<br>
- CurAbbrevs.pop_back();<br>
- CurBlockInfo->Abbrevs.push_back(Abbv);<br>
- continue;<br>
- }<br>
-<br>
- // Read a record.<br>
- Record.clear();<br>
- switch (ReadRecord(Code, Record)) {<br>
- default: break; // Default behavior, ignore unknown content.<br>
- case bitc::BLOCKINFO_CODE_SETBID:<br>
- if (Record.size() < 1) return true;<br>
- CurBlockInfo = &BitStream->getOrCreateBlockInfo((unsigned)Record[0]);<br>
- break;<br>
- case bitc::BLOCKINFO_CODE_BLOCKNAME: {<br>
- if (!CurBlockInfo) return true;<br>
- if (BitStream->isIgnoringBlockInfoNames()) break; // Ignore name.<br>
- std::string Name;<br>
- for (unsigned i = 0, e = Record.size(); i != e; ++i)<br>
- Name += (char)Record[i];<br>
- CurBlockInfo->Name = Name;<br>
- break;<br>
- }<br>
- case bitc::BLOCKINFO_CODE_SETRECORDNAME: {<br>
- if (!CurBlockInfo) return true;<br>
- if (BitStream->isIgnoringBlockInfoNames()) break; // Ignore name.<br>
- std::string Name;<br>
- for (unsigned i = 1, e = Record.size(); i != e; ++i)<br>
- Name += (char)Record[i];<br>
- CurBlockInfo->RecordNames.push_back(std::make_pair((unsigned)Record[0],<br>
- Name));<br>
- break;<br>
- }<br>
- }<br>
- }<br>
- }<br>
+ void ReadAbbrevRecord();<br>
+<br>
+ bool ReadBlockInfoBlock();<br>
};<br>
<br>
} // End llvm namespace<br>
<br>
Modified: llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=172904&r1=172903&r2=172904&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp?rev=172904&r1=172903&r2=172904&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp (original)<br>
+++ llvm/trunk/lib/Bitcode/Reader/BitcodeReader.cpp Sat Jan 19 12:19:39 2013<br>
@@ -6,10 +6,6 @@<br>
// License. See LICENSE.TXT for details.<br>
//<br>
//===----------------------------------------------------------------------===//<br>
-//<br>
-// This header defines the BitcodeReader class.<br>
-//<br>
-//===----------------------------------------------------------------------===//<br>
<br>
#include "llvm/Bitcode/ReaderWriter.h"<br>
#include "BitcodeReader.h"<br>
<br>
Added: llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp?rev=172904&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp?rev=172904&view=auto</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp (added)<br>
+++ llvm/trunk/lib/Bitcode/Reader/BitstreamReader.cpp Sat Jan 19 12:19:39 2013<br>
@@ -0,0 +1,253 @@<br>
+//===- BitstreamReader.cpp - BitstreamReader implementation ---------------===//<br>
+//<br>
+// The LLVM Compiler Infrastructure<br>
+//<br>
+// This file is distributed under the University of Illinois Open Source<br>
+// License. See LICENSE.TXT for details.<br>
+//<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+#include "llvm/Bitcode/BitstreamReader.h"<br>
+<br>
+using namespace llvm;<br>
+<br>
+//===----------------------------------------------------------------------===//<br>
+// BitstreamCursor implementation<br>
+//===----------------------------------------------------------------------===//<br>
+<br>
+void BitstreamCursor::operator=(const BitstreamCursor &RHS) {<br>
+ freeState();<br>
+<br>
+ BitStream = RHS.BitStream;<br>
+ NextChar = RHS.NextChar;<br>
+ CurWord = RHS.CurWord;<br>
+ BitsInCurWord = RHS.BitsInCurWord;<br>
+ CurCodeSize = RHS.CurCodeSize;<br>
+<br>
+ // Copy abbreviations, and bump ref counts.<br>
+ CurAbbrevs = RHS.CurAbbrevs;<br>
+ for (unsigned i = 0, e = static_cast<unsigned>(CurAbbrevs.size());<br>
+ i != e; ++i)<br>
+ CurAbbrevs[i]->addRef();<br>
+<br>
+ // Copy block scope and bump ref counts.<br>
+ BlockScope = RHS.BlockScope;<br>
+ for (unsigned S = 0, e = static_cast<unsigned>(BlockScope.size());<br>
+ S != e; ++S) {<br>
+ std::vector<BitCodeAbbrev*> &Abbrevs = BlockScope[S].PrevAbbrevs;<br>
+ for (unsigned i = 0, e = static_cast<unsigned>(Abbrevs.size());<br>
+ i != e; ++i)<br>
+ Abbrevs[i]->addRef();<br>
+ }<br>
+}<br>
+<br>
+void BitstreamCursor::freeState() {<br>
+ // Free all the Abbrevs.<br>
+ for (unsigned i = 0, e = static_cast<unsigned>(CurAbbrevs.size());<br>
+ i != e; ++i)<br>
+ CurAbbrevs[i]->dropRef();<br>
+ CurAbbrevs.clear();<br>
+<br>
+ // Free all the Abbrevs in the block scope.<br>
+ for (unsigned S = 0, e = static_cast<unsigned>(BlockScope.size());<br>
+ S != e; ++S) {<br>
+ std::vector<BitCodeAbbrev*> &Abbrevs = BlockScope[S].PrevAbbrevs;<br>
+ for (unsigned i = 0, e = static_cast<unsigned>(Abbrevs.size());<br>
+ i != e; ++i)<br>
+ Abbrevs[i]->dropRef();<br>
+ }<br>
+ BlockScope.clear();<br>
+}<br>
+<br>
+/// EnterSubBlock - Having read the ENTER_SUBBLOCK abbrevid, enter<br>
+/// the block, and return true if the block has an error.<br>
+bool BitstreamCursor::EnterSubBlock(unsigned BlockID, unsigned *NumWordsP) {<br>
+ // Save the current block's state on BlockScope.<br>
+ BlockScope.push_back(Block(CurCodeSize));<br>
+ BlockScope.back().PrevAbbrevs.swap(CurAbbrevs);<br>
+<br>
+ // Add the abbrevs specific to this block to the CurAbbrevs list.<br>
+ if (const BitstreamReader::BlockInfo *Info =<br>
+ BitStream->getBlockInfo(BlockID)) {<br>
+ for (unsigned i = 0, e = static_cast<unsigned>(Info->Abbrevs.size());<br>
+ i != e; ++i) {<br>
+ CurAbbrevs.push_back(Info->Abbrevs[i]);<br>
+ CurAbbrevs.back()->addRef();<br>
+ }<br>
+ }<br>
+<br>
+ // Get the codesize of this block.<br>
+ CurCodeSize = ReadVBR(bitc::CodeLenWidth);<br>
+ SkipToWord();<br>
+ unsigned NumWords = Read(bitc::BlockSizeWidth);<br>
+ if (NumWordsP) *NumWordsP = NumWords;<br>
+<br>
+ // Validate that this block is sane.<br>
+ if (CurCodeSize == 0 || AtEndOfStream())<br>
+ return true;<br>
+<br>
+ return false;<br>
+}<br>
+<br>
+<br>
+unsigned BitstreamCursor::ReadRecord(unsigned AbbrevID,<br>
+ SmallVectorImpl<uint64_t> &Vals,<br>
+ const char **BlobStart, unsigned *BlobLen){<br>
+ if (AbbrevID == bitc::UNABBREV_RECORD) {<br>
+ unsigned Code = ReadVBR(6);<br>
+ unsigned NumElts = ReadVBR(6);<br>
+ for (unsigned i = 0; i != NumElts; ++i)<br>
+ Vals.push_back(ReadVBR64(6));<br>
+ return Code;<br>
+ }<br>
+<br>
+ const BitCodeAbbrev *Abbv = getAbbrev(AbbrevID);<br>
+<br>
+ for (unsigned i = 0, e = Abbv->getNumOperandInfos(); i != e; ++i) {<br>
+ const BitCodeAbbrevOp &Op = Abbv->getOperandInfo(i);<br>
+ if (Op.isLiteral()) {<br>
+ ReadAbbreviatedLiteral(Op, Vals);<br>
+ continue;<br>
+ }<br>
+<br>
+ if (Op.getEncoding() != BitCodeAbbrevOp::Array &&<br>
+ Op.getEncoding() != BitCodeAbbrevOp::Blob) {<br>
+ ReadAbbreviatedField(Op, Vals);<br>
+ continue;<br>
+ }<br>
+<br>
+ if (Op.getEncoding() == BitCodeAbbrevOp::Array) {<br>
+ // Array case. Read the number of elements as a vbr6.<br>
+ unsigned NumElts = ReadVBR(6);<br>
+<br>
+ // Get the element encoding.<br>
+ assert(i+2 == e && "array op not second to last?");<br>
+ const BitCodeAbbrevOp &EltEnc = Abbv->getOperandInfo(++i);<br>
+<br>
+ // Read all the elements.<br>
+ for (; NumElts; --NumElts)<br>
+ ReadAbbreviatedField(EltEnc, Vals);<br>
+ continue;<br>
+ }<br>
+<br>
+ assert(Op.getEncoding() == BitCodeAbbrevOp::Blob);<br>
+ // Blob case. Read the number of bytes as a vbr6.<br>
+ unsigned NumElts = ReadVBR(6);<br>
+ SkipToWord(); // 32-bit alignment<br>
+<br>
+ // Figure out where the end of this blob will be including tail padding.<br>
+ size_t NewEnd = NextChar+((NumElts+3)&~3);<br>
+<br>
+ // If this would read off the end of the bitcode file, just set the<br>
+ // record to empty and return.<br>
+ if (!canSkipToPos(NewEnd)) {<br>
+ Vals.append(NumElts, 0);<br>
+ NextChar = BitStream->getBitcodeBytes().getExtent();<br>
+ break;<br>
+ }<br>
+<br>
+ // Otherwise, read the number of bytes. If we can return a reference to<br>
+ // the data, do so to avoid copying it.<br>
+ if (BlobStart) {<br>
+ *BlobStart = (const char*)BitStream->getBitcodeBytes().getPointer(<br>
+ NextChar, NumElts);<br>
+ *BlobLen = NumElts;<br>
+ } else {<br>
+ for (; NumElts; ++NextChar, --NumElts)<br>
+ Vals.push_back(getByte(NextChar));<br>
+ }<br>
+ // Skip over tail padding.<br>
+ NextChar = NewEnd;<br>
+ }<br>
+<br>
+ unsigned Code = (unsigned)Vals[0];<br>
+ Vals.erase(Vals.begin());<br>
+ return Code;<br>
+}<br>
+<br>
+<br>
+void BitstreamCursor::ReadAbbrevRecord() {<br>
+ BitCodeAbbrev *Abbv = new BitCodeAbbrev();<br>
+ unsigned NumOpInfo = ReadVBR(5);<br>
+ for (unsigned i = 0; i != NumOpInfo; ++i) {<br>
+ bool IsLiteral = Read(1) ? true : false;<br>
+ if (IsLiteral) {<br>
+ Abbv->Add(BitCodeAbbrevOp(ReadVBR64(8)));<br>
+ continue;<br>
+ }<br>
+<br>
+ BitCodeAbbrevOp::Encoding E = (BitCodeAbbrevOp::Encoding)Read(3);<br>
+ if (BitCodeAbbrevOp::hasEncodingData(E))<br>
+ Abbv->Add(BitCodeAbbrevOp(E, ReadVBR64(5)));<br>
+ else<br>
+ Abbv->Add(BitCodeAbbrevOp(E));<br>
+ }<br>
+ CurAbbrevs.push_back(Abbv);<br>
+}<br>
+<br>
+bool BitstreamCursor::ReadBlockInfoBlock() {<br>
+ // If this is the second stream to get to the block info block, skip it.<br>
+ if (BitStream->hasBlockInfoRecords())<br>
+ return SkipBlock();<br>
+<br>
+ if (EnterSubBlock(bitc::BLOCKINFO_BLOCK_ID)) return true;<br>
+<br>
+ SmallVector<uint64_t, 64> Record;<br>
+ BitstreamReader::BlockInfo *CurBlockInfo = 0;<br>
+<br>
+ // Read all the records for this module.<br>
+ while (1) {<br>
+ unsigned Code = ReadCode();<br>
+ if (Code == bitc::END_BLOCK)<br>
+ return ReadBlockEnd();<br>
+ if (Code == bitc::ENTER_SUBBLOCK) {<br>
+ ReadSubBlockID();<br>
+ if (SkipBlock()) return true;<br>
+ continue;<br>
+ }<br>
+<br>
+ // Read abbrev records, associate them with CurBID.<br>
+ if (Code == bitc::DEFINE_ABBREV) {<br>
+ if (!CurBlockInfo) return true;<br>
+ ReadAbbrevRecord();<br>
+<br>
+ // ReadAbbrevRecord installs the abbrev in CurAbbrevs. Move it to the<br>
+ // appropriate BlockInfo.<br>
+ BitCodeAbbrev *Abbv = CurAbbrevs.back();<br>
+ CurAbbrevs.pop_back();<br>
+ CurBlockInfo->Abbrevs.push_back(Abbv);<br>
+ continue;<br>
+ }<br>
+<br>
+ // Read a record.<br>
+ Record.clear();<br>
+ switch (ReadRecord(Code, Record)) {<br>
+ default: break; // Default behavior, ignore unknown content.<br>
+ case bitc::BLOCKINFO_CODE_SETBID:<br>
+ if (Record.size() < 1) return true;<br>
+ CurBlockInfo = &BitStream->getOrCreateBlockInfo((unsigned)Record[0]);<br>
+ break;<br>
+ case bitc::BLOCKINFO_CODE_BLOCKNAME: {<br>
+ if (!CurBlockInfo) return true;<br>
+ if (BitStream->isIgnoringBlockInfoNames()) break; // Ignore name.<br>
+ std::string Name;<br>
+ for (unsigned i = 0, e = Record.size(); i != e; ++i)<br>
+ Name += (char)Record[i];<br>
+ CurBlockInfo->Name = Name;<br>
+ break;<br>
+ }<br>
+ case bitc::BLOCKINFO_CODE_SETRECORDNAME: {<br>
+ if (!CurBlockInfo) return true;<br>
+ if (BitStream->isIgnoringBlockInfoNames()) break; // Ignore name.<br>
+ std::string Name;<br>
+ for (unsigned i = 1, e = Record.size(); i != e; ++i)<br>
+ Name += (char)Record[i];<br>
+ CurBlockInfo->RecordNames.push_back(std::make_pair((unsigned)Record[0],<br>
+ Name));<br>
+ break;<br>
+ }<br>
+ }<br>
+ }<br>
+}<br>
+<br>
+<br>
<br>
Modified: llvm/trunk/lib/Bitcode/Reader/CMakeLists.txt<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/CMakeLists.txt?rev=172904&r1=172903&r2=172904&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Bitcode/Reader/CMakeLists.txt?rev=172904&r1=172903&r2=172904&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/Bitcode/Reader/CMakeLists.txt (original)<br>
+++ llvm/trunk/lib/Bitcode/Reader/CMakeLists.txt Sat Jan 19 12:19:39 2013<br>
@@ -1,6 +1,7 @@<br>
add_llvm_library(LLVMBitReader<br>
BitReader.cpp<br>
BitcodeReader.cpp<br>
+ BitstreamReader.cpp<br>
)<br>
<br>
add_dependencies(LLVMBitReader intrinsics_gen)<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>