1//===- BitcodeReader.cpp - Internal BitcodeReader implementation ----------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is distributed under the University of Illinois Open Source 6// License. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9// 10// This header defines the BitcodeReader class. 11// 12//===----------------------------------------------------------------------===// 13 14#include "llvm/Bitcode/ReaderWriter.h" 15#include "BitcodeReader.h" 16#include "llvm/Constants.h" 17#include "llvm/DerivedTypes.h" 18#include "llvm/InlineAsm.h" 19#include "llvm/IntrinsicInst.h" |
20#include "llvm/Module.h" 21#include "llvm/Operator.h" 22#include "llvm/AutoUpgrade.h" 23#include "llvm/ADT/SmallString.h" 24#include "llvm/ADT/SmallVector.h" 25#include "llvm/Support/MathExtras.h" 26#include "llvm/Support/MemoryBuffer.h" 27#include "llvm/OperandTraits.h" --- 805 unchanged lines hidden (view full) --- 833 if (Record.empty() || RecordLength < 2) 834 return Error("Invalid METADATA_KIND record"); 835 SmallString<8> Name; 836 Name.resize(RecordLength-1); 837 unsigned Kind = Record[0]; 838 (void) Kind; 839 for (unsigned i = 1; i != RecordLength; ++i) 840 Name[i-1] = Record[i]; |
841 842 unsigned NewKind = TheModule->getMDKindID(Name.str()); 843 assert(Kind == NewKind && 844 "FIXME: Unable to handle custom metadata mismatch!");(void)NewKind; |
845 break; 846 } 847 } 848 } 849} 850 851/// DecodeSignRotatedValue - Decode a signed value stored with the sign bit in 852/// the LSB for dense VBR encoding. --- 713 unchanged lines hidden (view full) --- 1566 return false; 1567} 1568 1569/// ParseMetadataAttachment - Parse metadata attachments. 1570bool BitcodeReader::ParseMetadataAttachment() { 1571 if (Stream.EnterSubBlock(bitc::METADATA_ATTACHMENT_ID)) 1572 return Error("Malformed block record"); 1573 |
1574 SmallVector<uint64_t, 64> Record; 1575 while(1) { 1576 unsigned Code = Stream.ReadCode(); 1577 if (Code == bitc::END_BLOCK) { 1578 if (Stream.ReadBlockEnd()) 1579 return Error("Error at end of PARAMATTR block"); 1580 break; 1581 } --- 9 unchanged lines hidden (view full) --- 1591 case bitc::METADATA_ATTACHMENT: { 1592 unsigned RecordLength = Record.size(); 1593 if (Record.empty() || (RecordLength - 1) % 2 == 1) 1594 return Error ("Invalid METADATA_ATTACHMENT reader!"); 1595 Instruction *Inst = InstructionList[Record[0]]; 1596 for (unsigned i = 1; i != RecordLength; i = i+2) { 1597 unsigned Kind = Record[i]; 1598 Value *Node = MDValueList.getValueFwdRef(Record[i+1]); |
1599 Inst->setMetadata(Kind, cast<MDNode>(Node)); |
1600 } 1601 break; 1602 } 1603 } 1604 } 1605 return false; 1606} 1607 --- 823 unchanged lines hidden --- |