BitcodeReader.cpp (198953) | BitcodeReader.cpp (201360) |
---|---|
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" | 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/LLVMContext.h" 21#include "llvm/Metadata.h" | |
22#include "llvm/Module.h" 23#include "llvm/Operator.h" 24#include "llvm/AutoUpgrade.h" 25#include "llvm/ADT/SmallString.h" 26#include "llvm/ADT/SmallVector.h" 27#include "llvm/Support/MathExtras.h" 28#include "llvm/Support/MemoryBuffer.h" 29#include "llvm/OperandTraits.h" --- 805 unchanged lines hidden (view full) --- 835 if (Record.empty() || RecordLength < 2) 836 return Error("Invalid METADATA_KIND record"); 837 SmallString<8> Name; 838 Name.resize(RecordLength-1); 839 unsigned Kind = Record[0]; 840 (void) Kind; 841 for (unsigned i = 1; i != RecordLength; ++i) 842 Name[i-1] = Record[i]; | 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]; |
843 MetadataContext &TheMetadata = Context.getMetadata(); 844 unsigned ExistingKind = TheMetadata.getMDKind(Name.str()); 845 if (ExistingKind == 0) { 846 unsigned NewKind = TheMetadata.registerMDKind(Name.str()); 847 (void) NewKind; 848 assert (Kind == NewKind 849 && "Unable to handle custom metadata mismatch!"); 850 } else { 851 assert (ExistingKind == Kind 852 && "Unable to handle custom metadata mismatch!"); 853 } | 841 842 unsigned NewKind = TheModule->getMDKindID(Name.str()); 843 assert(Kind == NewKind && 844 "FIXME: Unable to handle custom metadata mismatch!");(void)NewKind; |
854 break; 855 } 856 } 857 } 858} 859 860/// DecodeSignRotatedValue - Decode a signed value stored with the sign bit in 861/// the LSB for dense VBR encoding. --- 713 unchanged lines hidden (view full) --- 1575 return false; 1576} 1577 1578/// ParseMetadataAttachment - Parse metadata attachments. 1579bool BitcodeReader::ParseMetadataAttachment() { 1580 if (Stream.EnterSubBlock(bitc::METADATA_ATTACHMENT_ID)) 1581 return Error("Malformed block record"); 1582 | 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 |
1583 MetadataContext &TheMetadata = Context.getMetadata(); | |
1584 SmallVector<uint64_t, 64> Record; 1585 while(1) { 1586 unsigned Code = Stream.ReadCode(); 1587 if (Code == bitc::END_BLOCK) { 1588 if (Stream.ReadBlockEnd()) 1589 return Error("Error at end of PARAMATTR block"); 1590 break; 1591 } --- 9 unchanged lines hidden (view full) --- 1601 case bitc::METADATA_ATTACHMENT: { 1602 unsigned RecordLength = Record.size(); 1603 if (Record.empty() || (RecordLength - 1) % 2 == 1) 1604 return Error ("Invalid METADATA_ATTACHMENT reader!"); 1605 Instruction *Inst = InstructionList[Record[0]]; 1606 for (unsigned i = 1; i != RecordLength; i = i+2) { 1607 unsigned Kind = Record[i]; 1608 Value *Node = MDValueList.getValueFwdRef(Record[i+1]); | 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]); |
1609 TheMetadata.addMD(Kind, cast<MDNode>(Node), Inst); | 1599 Inst->setMetadata(Kind, cast<MDNode>(Node)); |
1610 } 1611 break; 1612 } 1613 } 1614 } 1615 return false; 1616} 1617 --- 823 unchanged lines hidden --- | 1600 } 1601 break; 1602 } 1603 } 1604 } 1605 return false; 1606} 1607 --- 823 unchanged lines hidden --- |