blob: 15be31f039789227e8c2de644cb9e35e624e0d73 [file] [log] [blame]
Chris Lattnercaee0dc2007-04-22 06:23:29 +00001//===- BitcodeReader.h - Internal BitcodeReader impl ------------*- C++ -*-===//
2//
3// The LLVM Compiler Infrastructure
4//
Chris Lattner4ee451d2007-12-29 20:36:04 +00005// This file is distributed under the University of Illinois Open Source
6// License. See LICENSE.TXT for details.
Chris Lattnercaee0dc2007-04-22 06:23:29 +00007//
8//===----------------------------------------------------------------------===//
9//
10// This header defines the BitcodeReader class.
11//
12//===----------------------------------------------------------------------===//
13
14#ifndef BITCODE_READER_H
15#define BITCODE_READER_H
16
Chandler Carrutha1514e22012-12-04 07:12:27 +000017#include "llvm/ADT/DenseMap.h"
Chris Lattner48f84872007-05-01 04:59:48 +000018#include "llvm/Bitcode/BitstreamReader.h"
Chris Lattner47f96bf2007-04-23 01:01:37 +000019#include "llvm/Bitcode/LLVMBitCodes.h"
Chandler Carruth0b8c9a82013-01-02 11:36:10 +000020#include "llvm/IR/Attributes.h"
Stephen Hines36b56882014-04-23 16:57:46 -070021#include "llvm/IR/GVMaterializer.h"
Chandler Carruth0b8c9a82013-01-02 11:36:10 +000022#include "llvm/IR/OperandTraits.h"
23#include "llvm/IR/Type.h"
Stephen Hines36b56882014-04-23 16:57:46 -070024#include "llvm/IR/ValueHandle.h"
Rafael Espindolae076b532013-11-04 16:16:24 +000025#include "llvm/Support/system_error.h"
Chris Lattnercaee0dc2007-04-22 06:23:29 +000026#include <vector>
27
28namespace llvm {
Chris Lattnerc453f762007-04-29 07:54:31 +000029 class MemoryBuffer;
Benjamin Kramer12ddd402009-08-11 17:45:13 +000030 class LLVMContext;
Joe Abbey170a15e2012-11-25 15:23:39 +000031
Gabor Greifefe65362008-05-10 08:32:32 +000032//===----------------------------------------------------------------------===//
33// BitcodeReaderValueList Class
34//===----------------------------------------------------------------------===//
35
Benjamin Kramer55c06ae2013-09-11 18:05:11 +000036class BitcodeReaderValueList {
Chris Lattner46e77402009-03-31 22:55:09 +000037 std::vector<WeakVH> ValuePtrs;
Joe Abbey170a15e2012-11-25 15:23:39 +000038
Chris Lattnerea693df2008-08-21 02:34:16 +000039 /// ResolveConstants - As we resolve forward-referenced constants, we add
40 /// information about them to this vector. This allows us to resolve them in
41 /// bulk instead of resolving each reference at a time. See the code in
42 /// ResolveConstantForwardRefs for more information about this.
43 ///
44 /// The key of this vector is the placeholder constant, the value is the slot
45 /// number that holds the resolved value.
46 typedef std::vector<std::pair<Constant*, unsigned> > ResolveConstantsTy;
47 ResolveConstantsTy ResolveConstants;
Chris Lattner7af453a2011-07-07 05:12:37 +000048 LLVMContext &Context;
Chris Lattner522b7b12007-04-24 05:48:56 +000049public:
Chris Lattner7af453a2011-07-07 05:12:37 +000050 BitcodeReaderValueList(LLVMContext &C) : Context(C) {}
Chris Lattnerea693df2008-08-21 02:34:16 +000051 ~BitcodeReaderValueList() {
52 assert(ResolveConstants.empty() && "Constants not resolved?");
53 }
Gabor Greifefe65362008-05-10 08:32:32 +000054
Chris Lattner522b7b12007-04-24 05:48:56 +000055 // vector compatibility methods
Chris Lattner46e77402009-03-31 22:55:09 +000056 unsigned size() const { return ValuePtrs.size(); }
57 void resize(unsigned N) { ValuePtrs.resize(N); }
Chris Lattner522b7b12007-04-24 05:48:56 +000058 void push_back(Value *V) {
Chris Lattner46e77402009-03-31 22:55:09 +000059 ValuePtrs.push_back(V);
Chris Lattner522b7b12007-04-24 05:48:56 +000060 }
Joe Abbey170a15e2012-11-25 15:23:39 +000061
Chris Lattnerb348bb82007-05-18 04:02:46 +000062 void clear() {
Chris Lattnerea693df2008-08-21 02:34:16 +000063 assert(ResolveConstants.empty() && "Constants not resolved?");
Chris Lattner46e77402009-03-31 22:55:09 +000064 ValuePtrs.clear();
Chris Lattnerb348bb82007-05-18 04:02:46 +000065 }
Joe Abbey170a15e2012-11-25 15:23:39 +000066
Chris Lattner46e77402009-03-31 22:55:09 +000067 Value *operator[](unsigned i) const {
68 assert(i < ValuePtrs.size());
69 return ValuePtrs[i];
70 }
Joe Abbey170a15e2012-11-25 15:23:39 +000071
Chris Lattner46e77402009-03-31 22:55:09 +000072 Value *back() const { return ValuePtrs.back(); }
73 void pop_back() { ValuePtrs.pop_back(); }
74 bool empty() const { return ValuePtrs.empty(); }
Chris Lattner198f34a2007-04-26 03:27:58 +000075 void shrinkTo(unsigned N) {
Chris Lattner46e77402009-03-31 22:55:09 +000076 assert(N <= size() && "Invalid shrinkTo request!");
77 ValuePtrs.resize(N);
Chris Lattner198f34a2007-04-26 03:27:58 +000078 }
Joe Abbey170a15e2012-11-25 15:23:39 +000079
Chris Lattnerdb125cf2011-07-18 04:54:35 +000080 Constant *getConstantFwdRef(unsigned Idx, Type *Ty);
81 Value *getValueFwdRef(unsigned Idx, Type *Ty);
Joe Abbey170a15e2012-11-25 15:23:39 +000082
Chris Lattner46e77402009-03-31 22:55:09 +000083 void AssignValue(Value *V, unsigned Idx);
Joe Abbey170a15e2012-11-25 15:23:39 +000084
Chris Lattnerea693df2008-08-21 02:34:16 +000085 /// ResolveConstantForwardRefs - Once all constants are read, this method bulk
86 /// resolves any forward references.
87 void ResolveConstantForwardRefs();
Chris Lattner522b7b12007-04-24 05:48:56 +000088};
Gabor Greifefe65362008-05-10 08:32:32 +000089
Devang Pateld5ac4042009-08-04 06:00:18 +000090
91//===----------------------------------------------------------------------===//
92// BitcodeReaderMDValueList Class
93//===----------------------------------------------------------------------===//
94
Benjamin Kramer55c06ae2013-09-11 18:05:11 +000095class BitcodeReaderMDValueList {
Devang Pateld5ac4042009-08-04 06:00:18 +000096 std::vector<WeakVH> MDValuePtrs;
Joe Abbey170a15e2012-11-25 15:23:39 +000097
Chris Lattner50b136d2009-10-28 05:53:48 +000098 LLVMContext &Context;
Devang Pateld5ac4042009-08-04 06:00:18 +000099public:
100 BitcodeReaderMDValueList(LLVMContext& C) : Context(C) {}
101
102 // vector compatibility methods
103 unsigned size() const { return MDValuePtrs.size(); }
104 void resize(unsigned N) { MDValuePtrs.resize(N); }
105 void push_back(Value *V) { MDValuePtrs.push_back(V); }
106 void clear() { MDValuePtrs.clear(); }
107 Value *back() const { return MDValuePtrs.back(); }
108 void pop_back() { MDValuePtrs.pop_back(); }
109 bool empty() const { return MDValuePtrs.empty(); }
Joe Abbey170a15e2012-11-25 15:23:39 +0000110
Devang Pateld5ac4042009-08-04 06:00:18 +0000111 Value *operator[](unsigned i) const {
112 assert(i < MDValuePtrs.size());
113 return MDValuePtrs[i];
114 }
Joe Abbey170a15e2012-11-25 15:23:39 +0000115
Devang Pateld5ac4042009-08-04 06:00:18 +0000116 void shrinkTo(unsigned N) {
117 assert(N <= size() && "Invalid shrinkTo request!");
118 MDValuePtrs.resize(N);
119 }
120
121 Value *getValueFwdRef(unsigned Idx);
122 void AssignValue(Value *V, unsigned Idx);
123};
124
Benjamin Kramer55c06ae2013-09-11 18:05:11 +0000125class BitcodeReader : public GVMaterializer {
Chris Lattner50b136d2009-10-28 05:53:48 +0000126 LLVMContext &Context;
Jeffrey Yasskinf0356fe2010-01-27 20:34:15 +0000127 Module *TheModule;
Chris Lattnerc453f762007-04-29 07:54:31 +0000128 MemoryBuffer *Buffer;
Jeffrey Yasskinf0356fe2010-01-27 20:34:15 +0000129 bool BufferOwned;
Stephen Hines36b56882014-04-23 16:57:46 -0700130 std::unique_ptr<BitstreamReader> StreamFile;
Chris Lattner962dde32009-04-26 20:59:02 +0000131 BitstreamCursor Stream;
Derek Schuff2ea93872012-02-06 22:30:29 +0000132 DataStreamer *LazyStreamer;
133 uint64_t NextUnreadBit;
134 bool SeenValueSymbolTable;
Joe Abbey170a15e2012-11-25 15:23:39 +0000135
Chris Lattner1afcace2011-07-09 17:41:24 +0000136 std::vector<Type*> TypeList;
Chris Lattner522b7b12007-04-24 05:48:56 +0000137 BitcodeReaderValueList ValueList;
Devang Pateld5ac4042009-08-04 06:00:18 +0000138 BitcodeReaderMDValueList MDValueList;
Devang Patele8e02132009-09-18 19:26:43 +0000139 SmallVector<Instruction *, 64> InstructionList;
Chad Rosiercbbb0962011-12-07 21:44:12 +0000140 SmallVector<SmallVector<uint64_t, 64>, 64> UseListRecords;
Devang Patele8e02132009-09-18 19:26:43 +0000141
Chris Lattnere16504e2007-04-24 03:30:34 +0000142 std::vector<std::pair<GlobalVariable*, unsigned> > GlobalInits;
Chris Lattner07d98b42007-04-26 02:46:40 +0000143 std::vector<std::pair<GlobalAlias*, unsigned> > AliasInits;
Peter Collingbourne1e3037f2013-09-16 01:08:15 +0000144 std::vector<std::pair<Function*, unsigned> > FunctionPrefixes;
Joe Abbey170a15e2012-11-25 15:23:39 +0000145
Manman Ren804f0342013-09-28 00:22:27 +0000146 SmallVector<Instruction*, 64> InstsWithTBAATag;
147
Devang Patel19c87462008-09-26 22:53:05 +0000148 /// MAttributes - The set of attributes by index. Index zero in the
Chris Lattner48c85b82007-05-04 03:30:17 +0000149 /// file is for null, and is thus not represented here. As such all indices
150 /// are off by one.
Bill Wendling99faa3b2012-12-07 23:16:57 +0000151 std::vector<AttributeSet> MAttributes;
Joe Abbey170a15e2012-11-25 15:23:39 +0000152
Bill Wendlingc3ba0a82013-02-10 23:24:25 +0000153 /// \brief The set of attribute groups.
Bill Wendling04ef4be2013-02-11 22:32:29 +0000154 std::map<unsigned, AttributeSet> MAttributeGroups;
Bill Wendlingc3ba0a82013-02-10 23:24:25 +0000155
Chris Lattner980e5aa2007-05-01 05:52:21 +0000156 /// FunctionBBs - While parsing a function body, this is a list of the basic
157 /// blocks for the function.
158 std::vector<BasicBlock*> FunctionBBs;
Joe Abbey170a15e2012-11-25 15:23:39 +0000159
Chris Lattner48f84872007-05-01 04:59:48 +0000160 // When reading the module header, this list is populated with functions that
161 // have bodies later in the file.
162 std::vector<Function*> FunctionsWithBodies;
Chandler Carruth69940402007-08-04 01:51:18 +0000163
Joe Abbey170a15e2012-11-25 15:23:39 +0000164 // When intrinsic functions are encountered which require upgrading they are
Chandler Carruth69940402007-08-04 01:51:18 +0000165 // stored here with their replacement function.
166 typedef std::vector<std::pair<Function*, Function*> > UpgradedIntrinsicMap;
167 UpgradedIntrinsicMap UpgradedIntrinsics;
Dan Gohman19538d12010-07-20 21:42:28 +0000168
169 // Map the bitcode's custom MDKind ID to the Module's MDKind ID.
170 DenseMap<unsigned, unsigned> MDKindMap;
Joe Abbey170a15e2012-11-25 15:23:39 +0000171
Derek Schuff2ea93872012-02-06 22:30:29 +0000172 // Several operations happen after the module header has been read, but
173 // before function bodies are processed. This keeps track of whether
174 // we've done this yet.
175 bool SeenFirstFunctionBody;
Joe Abbey170a15e2012-11-25 15:23:39 +0000176
Chris Lattner48f84872007-05-01 04:59:48 +0000177 /// DeferredFunctionInfo - When function bodies are initially scanned, this
Jeffrey Yasskinf0356fe2010-01-27 20:34:15 +0000178 /// map contains info about where to find deferred function body in the
179 /// stream.
180 DenseMap<Function*, uint64_t> DeferredFunctionInfo;
Joe Abbey170a15e2012-11-25 15:23:39 +0000181
Chris Lattner50b136d2009-10-28 05:53:48 +0000182 /// BlockAddrFwdRefs - These are blockaddr references to basic blocks. These
183 /// are resolved lazily when functions are loaded.
184 typedef std::pair<unsigned, GlobalVariable*> BlockAddrRefTy;
185 DenseMap<Function*, std::vector<BlockAddrRefTy> > BlockAddrFwdRefs;
Dan Gohman9b10dfb2010-09-13 18:00:48 +0000186
Jan Wen Voungd9a3bad2012-10-11 20:20:40 +0000187 /// UseRelativeIDs - Indicates that we are using a new encoding for
Jan Wen Voung7b8d9492012-10-11 21:45:16 +0000188 /// instruction operands where most operands in the current
Jan Wen Voungd9a3bad2012-10-11 20:20:40 +0000189 /// FUNCTION_BLOCK are encoded relative to the instruction number,
190 /// for a more compact encoding. Some instruction operands are not
191 /// relative to the instruction ID: basic block numbers, and types.
192 /// Once the old style function blocks have been phased out, we would
193 /// not need this flag.
194 bool UseRelativeIDs;
195
Rafael Espindolae076b532013-11-04 16:16:24 +0000196 static const error_category &BitcodeErrorCategory();
197
Chris Lattnercaee0dc2007-04-22 06:23:29 +0000198public:
Rafael Espindolae076b532013-11-04 16:16:24 +0000199 enum ErrorType {
200 BitcodeStreamInvalidSize,
201 ConflictingMETADATA_KINDRecords,
202 CouldNotFindFunctionInStream,
203 ExpectedConstant,
204 InsufficientFunctionProtos,
205 InvalidBitcodeSignature,
206 InvalidBitcodeWrapperHeader,
207 InvalidConstantReference,
208 InvalidID, // A read identifier is not found in the table it should be in.
209 InvalidInstructionWithNoBB,
210 InvalidRecord, // A read record doesn't have the expected size or structure
211 InvalidTypeForValue, // Type read OK, but is invalid for its use
212 InvalidTYPETable,
213 InvalidType, // We were unable to read a type
214 MalformedBlock, // We are unable to advance in the stream.
215 MalformedGlobalInitializerSet,
216 InvalidMultipleBlocks, // We found multiple blocks of a kind that should
217 // have only one
218 NeverResolvedValueFoundInFunction,
219 InvalidValue // Invalid version, inst number, attr number, etc
220 };
221
222 error_code Error(ErrorType E) {
223 return error_code(E, BitcodeErrorCategory());
224 }
225
Chris Lattner08113472009-12-29 09:01:33 +0000226 explicit BitcodeReader(MemoryBuffer *buffer, LLVMContext &C)
Jeffrey Yasskinf0356fe2010-01-27 20:34:15 +0000227 : Context(C), TheModule(0), Buffer(buffer), BufferOwned(false),
Derek Schuff0ffe6982012-02-29 00:07:09 +0000228 LazyStreamer(0), NextUnreadBit(0), SeenValueSymbolTable(false),
Rafael Espindolae076b532013-11-04 16:16:24 +0000229 ValueList(C), MDValueList(C),
Jan Wen Voungd9a3bad2012-10-11 20:20:40 +0000230 SeenFirstFunctionBody(false), UseRelativeIDs(false) {
Derek Schuff2ea93872012-02-06 22:30:29 +0000231 }
232 explicit BitcodeReader(DataStreamer *streamer, LLVMContext &C)
233 : Context(C), TheModule(0), Buffer(0), BufferOwned(false),
Derek Schuff0ffe6982012-02-29 00:07:09 +0000234 LazyStreamer(streamer), NextUnreadBit(0), SeenValueSymbolTable(false),
Rafael Espindolae076b532013-11-04 16:16:24 +0000235 ValueList(C), MDValueList(C),
Jan Wen Voungd9a3bad2012-10-11 20:20:40 +0000236 SeenFirstFunctionBody(false), UseRelativeIDs(false) {
Chris Lattner48f84872007-05-01 04:59:48 +0000237 }
Chris Lattnerb348bb82007-05-18 04:02:46 +0000238 ~BitcodeReader() {
239 FreeState();
240 }
Rafael Espindola47f79bb2012-01-02 07:49:53 +0000241
242 void materializeForwardReferencedFunctions();
243
Chris Lattnerb348bb82007-05-18 04:02:46 +0000244 void FreeState();
Joe Abbey170a15e2012-11-25 15:23:39 +0000245
Jeffrey Yasskinf0356fe2010-01-27 20:34:15 +0000246 /// setBufferOwned - If this is true, the reader will destroy the MemoryBuffer
247 /// when the reader is destroyed.
248 void setBufferOwned(bool Owned) { BufferOwned = Owned; }
Joe Abbey170a15e2012-11-25 15:23:39 +0000249
Stephen Hines36b56882014-04-23 16:57:46 -0700250 bool isMaterializable(const GlobalValue *GV) const override;
251 bool isDematerializable(const GlobalValue *GV) const override;
252 error_code Materialize(GlobalValue *GV) override;
253 error_code MaterializeModule(Module *M) override;
254 void Dematerialize(GlobalValue *GV) override;
Chris Lattnerd67c6322007-05-15 06:29:44 +0000255
Chris Lattnercaee0dc2007-04-22 06:23:29 +0000256 /// @brief Main interface to parsing a bitcode buffer.
257 /// @returns true if an error occurred.
Rafael Espindolae076b532013-11-04 16:16:24 +0000258 error_code ParseBitcodeInto(Module *M);
Bill Wendling34711742010-10-06 01:22:42 +0000259
260 /// @brief Cheap mechanism to just extract module triple
261 /// @returns true if an error occurred.
Rafael Espindolae076b532013-11-04 16:16:24 +0000262 error_code ParseTriple(std::string &Triple);
Jan Wen Voungd9a3bad2012-10-11 20:20:40 +0000263
264 static uint64_t decodeSignRotatedValue(uint64_t V);
265
Chris Lattnercaee0dc2007-04-22 06:23:29 +0000266private:
Chris Lattner1afcace2011-07-09 17:41:24 +0000267 Type *getTypeByID(unsigned ID);
Chris Lattnerdb125cf2011-07-18 04:54:35 +0000268 Value *getFnValueByID(unsigned ID, Type *Ty) {
Chris Lattnercbd40f82011-07-07 05:29:18 +0000269 if (Ty && Ty->isMetadataTy())
Devang Pateld5ac4042009-08-04 06:00:18 +0000270 return MDValueList.getValueFwdRef(ID);
Chris Lattner7af453a2011-07-07 05:12:37 +0000271 return ValueList.getValueFwdRef(ID, Ty);
Chris Lattnera7c49aa2007-05-01 07:01:57 +0000272 }
Chris Lattnerf4c8e522007-05-02 05:46:45 +0000273 BasicBlock *getBasicBlock(unsigned ID) const {
274 if (ID >= FunctionBBs.size()) return 0; // Invalid ID
275 return FunctionBBs[ID];
276 }
Bill Wendling99faa3b2012-12-07 23:16:57 +0000277 AttributeSet getAttributes(unsigned i) const {
Devang Patel19c87462008-09-26 22:53:05 +0000278 if (i-1 < MAttributes.size())
279 return MAttributes[i-1];
Bill Wendling99faa3b2012-12-07 23:16:57 +0000280 return AttributeSet();
Chris Lattner48c85b82007-05-04 03:30:17 +0000281 }
Joe Abbey170a15e2012-11-25 15:23:39 +0000282
Chris Lattner7337ab92007-05-06 00:00:00 +0000283 /// getValueTypePair - Read a value/type pair out of the specified record from
284 /// slot 'Slot'. Increment Slot past the number of slots used in the record.
285 /// Return true on failure.
Craig Topper9e639e82013-07-11 16:22:38 +0000286 bool getValueTypePair(SmallVectorImpl<uint64_t> &Record, unsigned &Slot,
Chris Lattner7337ab92007-05-06 00:00:00 +0000287 unsigned InstNum, Value *&ResVal) {
288 if (Slot == Record.size()) return true;
Jeff Cohen650c9382007-05-06 03:23:14 +0000289 unsigned ValNo = (unsigned)Record[Slot++];
Jan Wen Voungd9a3bad2012-10-11 20:20:40 +0000290 // Adjust the ValNo, if it was encoded relative to the InstNum.
291 if (UseRelativeIDs)
292 ValNo = InstNum - ValNo;
Chris Lattner7337ab92007-05-06 00:00:00 +0000293 if (ValNo < InstNum) {
294 // If this is not a forward reference, just return the value we already
295 // have.
296 ResVal = getFnValueByID(ValNo, 0);
297 return ResVal == 0;
298 } else if (Slot == Record.size()) {
299 return true;
300 }
Jan Wen Voungd9a3bad2012-10-11 20:20:40 +0000301
Jeff Cohen650c9382007-05-06 03:23:14 +0000302 unsigned TypeNo = (unsigned)Record[Slot++];
Chris Lattner7337ab92007-05-06 00:00:00 +0000303 ResVal = getFnValueByID(ValNo, getTypeByID(TypeNo));
304 return ResVal == 0;
305 }
Jan Wen Voungd9a3bad2012-10-11 20:20:40 +0000306
307 /// popValue - Read a value out of the specified record from slot 'Slot'.
308 /// Increment Slot past the number of slots used by the value in the record.
309 /// Return true if there is an error.
Craig Topper9e639e82013-07-11 16:22:38 +0000310 bool popValue(SmallVectorImpl<uint64_t> &Record, unsigned &Slot,
Jan Wen Voungd9a3bad2012-10-11 20:20:40 +0000311 unsigned InstNum, Type *Ty, Value *&ResVal) {
312 if (getValue(Record, Slot, InstNum, Ty, ResVal))
313 return true;
314 // All values currently take a single record slot.
315 ++Slot;
316 return false;
317 }
318
319 /// getValue -- Like popValue, but does not increment the Slot number.
Craig Topper9e639e82013-07-11 16:22:38 +0000320 bool getValue(SmallVectorImpl<uint64_t> &Record, unsigned Slot,
Jan Wen Voungd9a3bad2012-10-11 20:20:40 +0000321 unsigned InstNum, Type *Ty, Value *&ResVal) {
322 ResVal = getValue(Record, Slot, InstNum, Ty);
Chris Lattner7337ab92007-05-06 00:00:00 +0000323 return ResVal == 0;
324 }
Chris Lattner48c85b82007-05-04 03:30:17 +0000325
Jan Wen Voungd9a3bad2012-10-11 20:20:40 +0000326 /// getValue -- Version of getValue that returns ResVal directly,
327 /// or 0 if there is an error.
Craig Topper9e639e82013-07-11 16:22:38 +0000328 Value *getValue(SmallVectorImpl<uint64_t> &Record, unsigned Slot,
Jan Wen Voungd9a3bad2012-10-11 20:20:40 +0000329 unsigned InstNum, Type *Ty) {
330 if (Slot == Record.size()) return 0;
331 unsigned ValNo = (unsigned)Record[Slot];
332 // Adjust the ValNo, if it was encoded relative to the InstNum.
333 if (UseRelativeIDs)
334 ValNo = InstNum - ValNo;
335 return getFnValueByID(ValNo, Ty);
336 }
337
338 /// getValueSigned -- Like getValue, but decodes signed VBRs.
Craig Topper9e639e82013-07-11 16:22:38 +0000339 Value *getValueSigned(SmallVectorImpl<uint64_t> &Record, unsigned Slot,
Jan Wen Voungd9a3bad2012-10-11 20:20:40 +0000340 unsigned InstNum, Type *Ty) {
341 if (Slot == Record.size()) return 0;
342 unsigned ValNo = (unsigned)decodeSignRotatedValue(Record[Slot]);
343 // Adjust the ValNo, if it was encoded relative to the InstNum.
344 if (UseRelativeIDs)
345 ValNo = InstNum - ValNo;
346 return getFnValueByID(ValNo, Ty);
347 }
348
Rafael Espindolae076b532013-11-04 16:16:24 +0000349 error_code ParseAttrKind(uint64_t Code, Attribute::AttrKind *Kind);
350 error_code ParseModule(bool Resume);
351 error_code ParseAttributeBlock();
352 error_code ParseAttributeGroupBlock();
353 error_code ParseTypeTable();
354 error_code ParseTypeTableBody();
Chris Lattner1afcace2011-07-09 17:41:24 +0000355
Rafael Espindolae076b532013-11-04 16:16:24 +0000356 error_code ParseValueSymbolTable();
357 error_code ParseConstants();
358 error_code RememberAndSkipFunctionBody();
359 error_code ParseFunctionBody(Function *F);
360 error_code GlobalCleanup();
361 error_code ResolveGlobalAndAliasInits();
362 error_code ParseMetadata();
363 error_code ParseMetadataAttachment();
364 error_code ParseModuleTriple(std::string &Triple);
365 error_code ParseUseLists();
366 error_code InitStream();
367 error_code InitStreamFromBuffer();
368 error_code InitLazyStream();
Rafael Espindolae05744b2013-11-05 17:16:08 +0000369 error_code FindFunctionInStream(Function *F,
Derek Schuff2ea93872012-02-06 22:30:29 +0000370 DenseMap<Function*, uint64_t>::iterator DeferredFunctionInfoIterator);
Chris Lattnercaee0dc2007-04-22 06:23:29 +0000371};
Joe Abbey170a15e2012-11-25 15:23:39 +0000372
Chris Lattnercaee0dc2007-04-22 06:23:29 +0000373} // End llvm namespace
374
375#endif