blob: 9cc24b32cda09b6b78c5b4fd3b06b27776128bb8 [file] [log] [blame]
Chris Lattnerd6b65252001-10-24 01:15:12 +00001//===- Reader.cpp - Code to read bytecode files ---------------------------===//
John Criswellb576c942003-10-20 19:43:21 +00002//
3// The LLVM Compiler Infrastructure
4//
5// This file was developed by the LLVM research group and is distributed under
6// the University of Illinois Open Source License. See LICENSE.TXT for details.
7//
8//===----------------------------------------------------------------------===//
Chris Lattner00950542001-06-06 20:29:01 +00009//
10// This library implements the functionality defined in llvm/Bytecode/Reader.h
11//
12// Note that this library should be as fast as possible, reentrant, and
13// threadsafe!!
14//
Chris Lattner00950542001-06-06 20:29:01 +000015// TODO: Allow passing in an option to ignore the symbol table
16//
Chris Lattnerd6b65252001-10-24 01:15:12 +000017//===----------------------------------------------------------------------===//
Chris Lattner00950542001-06-06 20:29:01 +000018
Chris Lattner7061dc52001-12-03 18:02:31 +000019#include "ReaderInternals.h"
Chris Lattner00950542001-06-06 20:29:01 +000020#include "llvm/Bytecode/Reader.h"
21#include "llvm/Bytecode/Format.h"
Misha Brukman12c29d12003-09-22 23:38:23 +000022#include "llvm/Module.h"
23#include "Support/StringExtras.h"
Chris Lattner29b789b2003-11-19 17:27:18 +000024using namespace llvm;
Brian Gaeked0fde302003-11-11 22:41:34 +000025
Chris Lattner9e460f22003-10-04 20:00:03 +000026unsigned BytecodeParser::getTypeSlot(const Type *Ty) {
27 if (Ty->isPrimitiveType())
28 return Ty->getPrimitiveID();
29
30 // Check the function level types first...
31 TypeValuesListTy::iterator I = find(FunctionTypeValues.begin(),
32 FunctionTypeValues.end(), Ty);
33 if (I != FunctionTypeValues.end())
34 return FirstDerivedTyID + ModuleTypeValues.size() +
35 (&*I - &FunctionTypeValues[0]);
36
37 I = find(ModuleTypeValues.begin(), ModuleTypeValues.end(), Ty);
38 if (I == ModuleTypeValues.end())
39 throw std::string("Didn't find type in ModuleTypeValues.");
40 return FirstDerivedTyID + (&*I - &ModuleTypeValues[0]);
Chris Lattner00950542001-06-06 20:29:01 +000041}
42
43const Type *BytecodeParser::getType(unsigned ID) {
Chris Lattner927b1852003-10-09 20:22:47 +000044 if (ID < Type::NumPrimitiveIDs)
45 if (const Type *T = Type::getPrimitiveType((Type::PrimitiveID)ID))
46 return T;
Chris Lattner00950542001-06-06 20:29:01 +000047
Chris Lattner697954c2002-01-20 22:54:45 +000048 //cerr << "Looking up Type ID: " << ID << "\n";
Chris Lattner36392bc2003-10-08 21:18:57 +000049
Chris Lattner927b1852003-10-09 20:22:47 +000050 if (ID < Type::NumPrimitiveIDs)
51 if (const Type *T = Type::getPrimitiveType((Type::PrimitiveID)ID))
52 return T; // Asked for a primitive type...
Chris Lattner36392bc2003-10-08 21:18:57 +000053
54 // Otherwise, derived types need offset...
55 ID -= FirstDerivedTyID;
56
57 // Is it a module-level type?
58 if (ID < ModuleTypeValues.size())
59 return ModuleTypeValues[ID].get();
60
61 // Nope, is it a function-level type?
62 ID -= ModuleTypeValues.size();
63 if (ID < FunctionTypeValues.size())
64 return FunctionTypeValues[ID].get();
65
Chris Lattner927b1852003-10-09 20:22:47 +000066 throw std::string("Illegal type reference!");
Chris Lattner00950542001-06-06 20:29:01 +000067}
68
Chris Lattnerf0d92732003-10-13 14:34:59 +000069unsigned BytecodeParser::insertValue(Value *Val, unsigned type,
70 ValueTable &ValueTab) {
Chris Lattnercb7e2e22003-10-18 05:54:18 +000071 assert((!isa<Constant>(Val) || Val->getType()->isPrimitiveType() ||
Chris Lattner52e20b02003-03-19 20:54:26 +000072 !cast<Constant>(Val)->isNullValue()) &&
73 "Cannot read null values from bytecode!");
Chris Lattner1d670cc2001-09-07 16:37:43 +000074 assert(type != Type::TypeTyID && "Types should never be insertValue'd!");
Chris Lattner29b789b2003-11-19 17:27:18 +000075
Chris Lattner52e20b02003-03-19 20:54:26 +000076 if (ValueTab.size() <= type) {
77 unsigned OldSize = ValueTab.size();
78 ValueTab.resize(type+1);
Chris Lattner036b8aa2003-03-06 17:55:45 +000079 }
Chris Lattner00950542001-06-06 20:29:01 +000080
Chris Lattner29b789b2003-11-19 17:27:18 +000081 if (!ValueTab[type]) ValueTab[type] = new ValueList();
82
Chris Lattner00950542001-06-06 20:29:01 +000083 //cerr << "insertValue Values[" << type << "][" << ValueTab[type].size()
Misha Brukman12c29d12003-09-22 23:38:23 +000084 // << "] = " << Val << "\n";
Chris Lattner52e20b02003-03-19 20:54:26 +000085 ValueTab[type]->push_back(Val);
Chris Lattner00950542001-06-06 20:29:01 +000086
Chris Lattnercb7e2e22003-10-18 05:54:18 +000087 bool HasOffset = !Val->getType()->isPrimitiveType();
Chris Lattner52e20b02003-03-19 20:54:26 +000088 return ValueTab[type]->size()-1 + HasOffset;
89}
90
91
Chris Lattner36392bc2003-10-08 21:18:57 +000092Value *BytecodeParser::getValue(unsigned type, unsigned oNum, bool Create) {
93 assert(type != Type::TypeTyID && "getValue() cannot get types!");
Chris Lattner4ee8ef22003-10-08 22:52:54 +000094 assert(type != Type::LabelTyID && "getValue() cannot get blocks!");
Chris Lattner00950542001-06-06 20:29:01 +000095 unsigned Num = oNum;
Chris Lattner00950542001-06-06 20:29:01 +000096
Chris Lattnercb7e2e22003-10-18 05:54:18 +000097 if (type >= FirstDerivedTyID) {
Chris Lattner52e20b02003-03-19 20:54:26 +000098 if (Num == 0)
Chris Lattner36392bc2003-10-08 21:18:57 +000099 return Constant::getNullValue(getType(type));
Chris Lattner52e20b02003-03-19 20:54:26 +0000100 --Num;
Chris Lattner00950542001-06-06 20:29:01 +0000101 }
102
Chris Lattner29b789b2003-11-19 17:27:18 +0000103 if (type < ModuleValues.size() && ModuleValues[type]) {
Chris Lattner52e20b02003-03-19 20:54:26 +0000104 if (Num < ModuleValues[type]->size())
105 return ModuleValues[type]->getOperand(Num);
106 Num -= ModuleValues[type]->size();
107 }
108
Chris Lattner29b789b2003-11-19 17:27:18 +0000109 if (Values.size() > type && Values[type] && Num < Values[type]->size())
Chris Lattner52e20b02003-03-19 20:54:26 +0000110 return Values[type]->getOperand(Num);
Chris Lattner00950542001-06-06 20:29:01 +0000111
Chris Lattner74734132002-08-17 22:01:27 +0000112 if (!Create) return 0; // Do not create a placeholder?
Chris Lattner00950542001-06-06 20:29:01 +0000113
Chris Lattner8eb10ce2003-10-09 06:05:40 +0000114 std::pair<unsigned,unsigned> KeyValue(type, oNum);
115 std::map<std::pair<unsigned,unsigned>, Value*>::iterator I =
116 ForwardReferences.lower_bound(KeyValue);
117 if (I != ForwardReferences.end() && I->first == KeyValue)
118 return I->second; // We have already created this placeholder
119
Chris Lattnerbf43ac62003-10-09 06:14:26 +0000120 Value *Val = new Argument(getType(type));
Chris Lattner8eb10ce2003-10-09 06:05:40 +0000121 ForwardReferences.insert(I, std::make_pair(KeyValue, Val));
Chris Lattner36392bc2003-10-08 21:18:57 +0000122 return Val;
Chris Lattner00950542001-06-06 20:29:01 +0000123}
124
Chris Lattner4ee8ef22003-10-08 22:52:54 +0000125/// getBasicBlock - Get a particular numbered basic block, which might be a
126/// forward reference. This works together with ParseBasicBlock to handle these
127/// forward references in a clean manner.
128///
129BasicBlock *BytecodeParser::getBasicBlock(unsigned ID) {
130 // Make sure there is room in the table...
131 if (ParsedBasicBlocks.size() <= ID) ParsedBasicBlocks.resize(ID+1);
132
133 // First check to see if this is a backwards reference, i.e., ParseBasicBlock
134 // has already created this block, or if the forward reference has already
135 // been created.
136 if (ParsedBasicBlocks[ID])
137 return ParsedBasicBlocks[ID];
138
139 // Otherwise, the basic block has not yet been created. Do so and add it to
140 // the ParsedBasicBlocks list.
141 return ParsedBasicBlocks[ID] = new BasicBlock();
142}
143
Chris Lattnerbbd4b302002-10-14 03:33:02 +0000144/// getConstantValue - Just like getValue, except that it returns a null pointer
145/// only on error. It always returns a constant (meaning that if the value is
146/// defined, but is not a constant, that is an error). If the specified
147/// constant hasn't been parsed yet, a placeholder is defined and used. Later,
148/// after the real value is parsed, the placeholder is eliminated.
149///
Chris Lattner1c3673b2003-11-19 06:01:12 +0000150Constant *BytecodeParser::getConstantValue(unsigned TypeSlot, unsigned Slot) {
151 if (Value *V = getValue(TypeSlot, Slot, false))
Chris Lattnerc9456ca2003-10-09 20:41:16 +0000152 if (Constant *C = dyn_cast<Constant>(V))
153 return C; // If we already have the value parsed, just return it
Chris Lattner93361992004-01-15 18:45:25 +0000154 else if (GlobalValue *GV = dyn_cast<GlobalValue>(V))
155 // ConstantPointerRef's are an abomination, but at least they don't have
156 // to infest bytecode files.
157 return ConstantPointerRef::get(GV);
Chris Lattnerc9456ca2003-10-09 20:41:16 +0000158 else
159 throw std::string("Reference of a value is expected to be a constant!");
Chris Lattnerbbd4b302002-10-14 03:33:02 +0000160
Chris Lattner1c3673b2003-11-19 06:01:12 +0000161 const Type *Ty = getType(TypeSlot);
Chris Lattner52e20b02003-03-19 20:54:26 +0000162 std::pair<const Type*, unsigned> Key(Ty, Slot);
Chris Lattner29b789b2003-11-19 17:27:18 +0000163 ConstantRefsType::iterator I = ConstantFwdRefs.lower_bound(Key);
Chris Lattner52e20b02003-03-19 20:54:26 +0000164
Chris Lattner29b789b2003-11-19 17:27:18 +0000165 if (I != ConstantFwdRefs.end() && I->first == Key) {
Chris Lattnerbbd4b302002-10-14 03:33:02 +0000166 BCR_TRACE(5, "Previous forward ref found!\n");
Chris Lattner29b789b2003-11-19 17:27:18 +0000167 return I->second;
Chris Lattnerbbd4b302002-10-14 03:33:02 +0000168 } else {
169 // Create a placeholder for the constant reference and
170 // keep track of the fact that we have a forward ref to recycle it
171 BCR_TRACE(5, "Creating new forward ref to a constant!\n");
172 Constant *C = new ConstPHolder(Ty, Slot);
173
174 // Keep track of the fact that we have a forward ref to recycle it
Chris Lattner29b789b2003-11-19 17:27:18 +0000175 ConstantFwdRefs.insert(I, std::make_pair(Key, C));
Chris Lattnerbbd4b302002-10-14 03:33:02 +0000176 return C;
177 }
178}
179
Chris Lattner8d1dbd22003-12-01 07:05:31 +0000180/// ParseBasicBlock - In LLVM 1.0 bytecode files, we used to output one
181/// basicblock at a time. This method reads in one of the basicblock packets.
Chris Lattner4ee8ef22003-10-08 22:52:54 +0000182BasicBlock *BytecodeParser::ParseBasicBlock(const unsigned char *&Buf,
183 const unsigned char *EndBuf,
184 unsigned BlockNo) {
185 BasicBlock *BB;
186 if (ParsedBasicBlocks.size() == BlockNo)
187 ParsedBasicBlocks.push_back(BB = new BasicBlock());
188 else if (ParsedBasicBlocks[BlockNo] == 0)
189 BB = ParsedBasicBlocks[BlockNo] = new BasicBlock();
190 else
191 BB = ParsedBasicBlocks[BlockNo];
Chris Lattner00950542001-06-06 20:29:01 +0000192
Chris Lattnercb7e2e22003-10-18 05:54:18 +0000193 std::vector<unsigned> Args;
194 while (Buf < EndBuf)
195 ParseInstruction(Buf, EndBuf, Args, BB);
Chris Lattner00950542001-06-06 20:29:01 +0000196
Misha Brukman12c29d12003-09-22 23:38:23 +0000197 return BB;
Chris Lattner00950542001-06-06 20:29:01 +0000198}
199
Chris Lattner8d1dbd22003-12-01 07:05:31 +0000200
201/// ParseInstructionList - Parse all of the BasicBlock's & Instruction's in the
202/// body of a function. In post 1.0 bytecode files, we no longer emit basic
203/// block individually, in order to avoid per-basic-block overhead.
204unsigned BytecodeParser::ParseInstructionList(Function *F,
205 const unsigned char *&Buf,
206 const unsigned char *EndBuf) {
207 unsigned BlockNo = 0;
208 std::vector<unsigned> Args;
209
210 while (Buf < EndBuf) {
211 BasicBlock *BB;
212 if (ParsedBasicBlocks.size() == BlockNo)
213 ParsedBasicBlocks.push_back(BB = new BasicBlock());
214 else if (ParsedBasicBlocks[BlockNo] == 0)
215 BB = ParsedBasicBlocks[BlockNo] = new BasicBlock();
216 else
217 BB = ParsedBasicBlocks[BlockNo];
218 ++BlockNo;
219 F->getBasicBlockList().push_back(BB);
220
221 // Read instructions into this basic block until we get to a terminator
222 while (Buf < EndBuf && !BB->getTerminator())
223 ParseInstruction(Buf, EndBuf, Args, BB);
224
225 if (!BB->getTerminator())
226 throw std::string("Non-terminated basic block found!");
227 }
228
229 return BlockNo;
230}
231
Misha Brukman12c29d12003-09-22 23:38:23 +0000232void BytecodeParser::ParseSymbolTable(const unsigned char *&Buf,
Chris Lattner12e64652003-05-22 18:08:30 +0000233 const unsigned char *EndBuf,
Chris Lattner4ee8ef22003-10-08 22:52:54 +0000234 SymbolTable *ST,
235 Function *CurrentFunction) {
Chris Lattner39cacce2003-10-10 05:43:47 +0000236 // Allow efficient basic block lookup by number.
237 std::vector<BasicBlock*> BBMap;
238 if (CurrentFunction)
239 for (Function::iterator I = CurrentFunction->begin(),
240 E = CurrentFunction->end(); I != E; ++I)
241 BBMap.push_back(I);
242
Chris Lattner00950542001-06-06 20:29:01 +0000243 while (Buf < EndBuf) {
244 // Symtab block header: [num entries][type id number]
Chris Lattner7969dc22004-01-15 06:13:09 +0000245 unsigned NumEntries = read_vbr_uint(Buf, EndBuf);
246 unsigned Typ = read_vbr_uint(Buf, EndBuf);
Chris Lattner00950542001-06-06 20:29:01 +0000247 const Type *Ty = getType(Typ);
Chris Lattner927b1852003-10-09 20:22:47 +0000248 BCR_TRACE(3, "Plane Type: '" << *Ty << "' with " << NumEntries <<
Misha Brukman12c29d12003-09-22 23:38:23 +0000249 " entries\n");
Chris Lattner1d670cc2001-09-07 16:37:43 +0000250
Chris Lattner7dc3a2e2003-10-13 14:57:53 +0000251 for (unsigned i = 0; i != NumEntries; ++i) {
Chris Lattner00950542001-06-06 20:29:01 +0000252 // Symtab entry: [def slot #][name]
Chris Lattner7969dc22004-01-15 06:13:09 +0000253 unsigned slot = read_vbr_uint(Buf, EndBuf);
254 std::string Name = read_str(Buf, EndBuf);
Chris Lattner00950542001-06-06 20:29:01 +0000255
Chris Lattner4ee8ef22003-10-08 22:52:54 +0000256 Value *V = 0;
Chris Lattner36392bc2003-10-08 21:18:57 +0000257 if (Typ == Type::TypeTyID)
258 V = (Value*)getType(slot);
Chris Lattner4ee8ef22003-10-08 22:52:54 +0000259 else if (Typ == Type::LabelTyID) {
Chris Lattner39cacce2003-10-10 05:43:47 +0000260 if (slot < BBMap.size())
261 V = BBMap[slot];
262 } else {
Chris Lattner36392bc2003-10-08 21:18:57 +0000263 V = getValue(Typ, slot, false); // Find mapping...
Chris Lattner39cacce2003-10-10 05:43:47 +0000264 }
Chris Lattner36392bc2003-10-08 21:18:57 +0000265 if (V == 0) throw std::string("Failed value look-up.");
Chris Lattner52e20b02003-03-19 20:54:26 +0000266 BCR_TRACE(4, "Map: '" << Name << "' to #" << slot << ":" << *V;
Misha Brukman12c29d12003-09-22 23:38:23 +0000267 if (!isa<Instruction>(V)) std::cerr << "\n");
Chris Lattner1d670cc2001-09-07 16:37:43 +0000268
Chris Lattner52e20b02003-03-19 20:54:26 +0000269 V->setName(Name, ST);
Chris Lattner00950542001-06-06 20:29:01 +0000270 }
271 }
272
Misha Brukman12c29d12003-09-22 23:38:23 +0000273 if (Buf > EndBuf) throw std::string("Tried to read past end of buffer.");
Chris Lattner00950542001-06-06 20:29:01 +0000274}
275
Chris Lattner29b789b2003-11-19 17:27:18 +0000276void BytecodeParser::ResolveReferencesToConstant(Constant *NewV, unsigned Slot){
277 ConstantRefsType::iterator I =
278 ConstantFwdRefs.find(std::make_pair(NewV->getType(), Slot));
279 if (I == ConstantFwdRefs.end()) return; // Never forward referenced?
Chris Lattner00950542001-06-06 20:29:01 +0000280
Chris Lattner74734132002-08-17 22:01:27 +0000281 BCR_TRACE(3, "Mutating forward refs!\n");
Chris Lattner29b789b2003-11-19 17:27:18 +0000282 Value *PH = I->second; // Get the placeholder...
283 PH->replaceAllUsesWith(NewV);
284 delete PH; // Delete the old placeholder
285 ConstantFwdRefs.erase(I); // Remove the map entry for it
Vikram S. Advec1e4a812002-07-14 23:04:18 +0000286}
287
Chris Lattner4ee8ef22003-10-08 22:52:54 +0000288void BytecodeParser::ParseFunction(const unsigned char *&Buf,
289 const unsigned char *EndBuf) {
Misha Brukman12c29d12003-09-22 23:38:23 +0000290 if (FunctionSignatureList.empty())
291 throw std::string("FunctionSignatureList empty!");
Chris Lattner52e20b02003-03-19 20:54:26 +0000292
Chris Lattner29b789b2003-11-19 17:27:18 +0000293 Function *F = FunctionSignatureList.back();
Misha Brukman12c29d12003-09-22 23:38:23 +0000294 FunctionSignatureList.pop_back();
295
296 // Save the information for future reading of the function
Chris Lattner29b789b2003-11-19 17:27:18 +0000297 LazyFunctionLoadMap[F] = LazyFunctionInfo(Buf, EndBuf);
Misha Brukman12c29d12003-09-22 23:38:23 +0000298 // Pretend we've `parsed' this function
299 Buf = EndBuf;
300}
301
302void BytecodeParser::materializeFunction(Function* F) {
303 // Find {start, end} pointers and slot in the map. If not there, we're done.
Chris Lattner29b789b2003-11-19 17:27:18 +0000304 std::map<Function*, LazyFunctionInfo>::iterator Fi =
Misha Brukman12c29d12003-09-22 23:38:23 +0000305 LazyFunctionLoadMap.find(F);
306 if (Fi == LazyFunctionLoadMap.end()) return;
Chris Lattner29b789b2003-11-19 17:27:18 +0000307
308 const unsigned char *Buf = Fi->second.Buf;
309 const unsigned char *EndBuf = Fi->second.EndBuf;
Misha Brukman12c29d12003-09-22 23:38:23 +0000310 LazyFunctionLoadMap.erase(Fi);
Chris Lattner00950542001-06-06 20:29:01 +0000311
Chris Lattnere3869c82003-04-16 21:16:05 +0000312 GlobalValue::LinkageTypes Linkage = GlobalValue::ExternalLinkage;
313
Chris Lattner7969dc22004-01-15 06:13:09 +0000314 unsigned LinkageType = read_vbr_uint(Buf, EndBuf);
Chris Lattnerc08912f2004-01-14 16:44:44 +0000315 if ((!hasExtendedLinkageSpecs && LinkageType > 3) ||
316 ( hasExtendedLinkageSpecs && LinkageType > 4))
317 throw std::string("Invalid linkage type for Function.");
318 switch (LinkageType) {
319 case 0: Linkage = GlobalValue::ExternalLinkage; break;
320 case 1: Linkage = GlobalValue::WeakLinkage; break;
321 case 2: Linkage = GlobalValue::AppendingLinkage; break;
322 case 3: Linkage = GlobalValue::InternalLinkage; break;
323 case 4: Linkage = GlobalValue::LinkOnceLinkage; break;
Chris Lattnere3869c82003-04-16 21:16:05 +0000324 }
Chris Lattnerd23b1d32001-11-26 18:56:10 +0000325
Chris Lattnere3869c82003-04-16 21:16:05 +0000326 F->setLinkage(Linkage);
Chris Lattner00950542001-06-06 20:29:01 +0000327
Chris Lattner52e20b02003-03-19 20:54:26 +0000328 const FunctionType::ParamTypes &Params =F->getFunctionType()->getParamTypes();
329 Function::aiterator AI = F->abegin();
Chris Lattnerc9aa7df2002-03-29 03:51:11 +0000330 for (FunctionType::ParamTypes::const_iterator It = Params.begin();
Chris Lattner927b1852003-10-09 20:22:47 +0000331 It != Params.end(); ++It, ++AI)
Chris Lattner29b789b2003-11-19 17:27:18 +0000332 insertValue(AI, getTypeSlot(AI->getType()), Values);
Chris Lattner00950542001-06-06 20:29:01 +0000333
Chris Lattner4ee8ef22003-10-08 22:52:54 +0000334 // Keep track of how many basic blocks we have read in...
335 unsigned BlockNum = 0;
336
Chris Lattner00950542001-06-06 20:29:01 +0000337 while (Buf < EndBuf) {
338 unsigned Type, Size;
Chris Lattnerb6c46952003-03-06 17:03:28 +0000339 const unsigned char *OldBuf = Buf;
Misha Brukman12c29d12003-09-22 23:38:23 +0000340 readBlock(Buf, EndBuf, Type, Size);
Chris Lattner00950542001-06-06 20:29:01 +0000341
342 switch (Type) {
Chris Lattner29b789b2003-11-19 17:27:18 +0000343 case BytecodeFormat::ConstantPool:
Chris Lattner1d670cc2001-09-07 16:37:43 +0000344 BCR_TRACE(2, "BLOCK BytecodeFormat::ConstantPool: {\n");
Misha Brukman12c29d12003-09-22 23:38:23 +0000345 ParseConstantPool(Buf, Buf+Size, Values, FunctionTypeValues);
Chris Lattner00950542001-06-06 20:29:01 +0000346 break;
347
348 case BytecodeFormat::BasicBlock: {
Chris Lattner1d670cc2001-09-07 16:37:43 +0000349 BCR_TRACE(2, "BLOCK BytecodeFormat::BasicBlock: {\n");
Chris Lattner4ee8ef22003-10-08 22:52:54 +0000350 BasicBlock *BB = ParseBasicBlock(Buf, Buf+Size, BlockNum++);
351 F->getBasicBlockList().push_back(BB);
Chris Lattner00950542001-06-06 20:29:01 +0000352 break;
353 }
354
Chris Lattner8d1dbd22003-12-01 07:05:31 +0000355 case BytecodeFormat::InstructionList: {
356 BCR_TRACE(2, "BLOCK BytecodeFormat::InstructionList: {\n");
357 if (BlockNum) throw std::string("Already parsed basic blocks!");
358 BlockNum = ParseInstructionList(F, Buf, Buf+Size);
359 break;
360 }
361
Chris Lattner29b789b2003-11-19 17:27:18 +0000362 case BytecodeFormat::SymbolTable:
Chris Lattner1d670cc2001-09-07 16:37:43 +0000363 BCR_TRACE(2, "BLOCK BytecodeFormat::SymbolTable: {\n");
Chris Lattner4ee8ef22003-10-08 22:52:54 +0000364 ParseSymbolTable(Buf, Buf+Size, &F->getSymbolTable(), F);
Chris Lattner00950542001-06-06 20:29:01 +0000365 break;
366
367 default:
Chris Lattner1d670cc2001-09-07 16:37:43 +0000368 BCR_TRACE(2, "BLOCK <unknown>:ignored! {\n");
Chris Lattner00950542001-06-06 20:29:01 +0000369 Buf += Size;
Misha Brukman12c29d12003-09-22 23:38:23 +0000370 if (OldBuf > Buf)
371 throw std::string("Wrapped around reading bytecode.");
Chris Lattner00950542001-06-06 20:29:01 +0000372 break;
373 }
Chris Lattner1d670cc2001-09-07 16:37:43 +0000374 BCR_TRACE(2, "} end block\n");
375
Misha Brukman12c29d12003-09-22 23:38:23 +0000376 // Malformed bc file if read past end of block.
Chris Lattner7969dc22004-01-15 06:13:09 +0000377 align32(Buf, EndBuf);
Chris Lattner00950542001-06-06 20:29:01 +0000378 }
379
Chris Lattner4ee8ef22003-10-08 22:52:54 +0000380 // Make sure there were no references to non-existant basic blocks.
381 if (BlockNum != ParsedBasicBlocks.size())
382 throw std::string("Illegal basic block operand reference");
383 ParsedBasicBlocks.clear();
384
Chris Lattner29b789b2003-11-19 17:27:18 +0000385
Chris Lattner97330cf2003-10-09 23:10:14 +0000386 // Resolve forward references. Replace any uses of a forward reference value
387 // with the real value.
Chris Lattner4ee8ef22003-10-08 22:52:54 +0000388
Chris Lattner97330cf2003-10-09 23:10:14 +0000389 // replaceAllUsesWith is very inefficient for instructions which have a LARGE
390 // number of operands. PHI nodes often have forward references, and can also
391 // often have a very large number of operands.
392 std::map<Value*, Value*> ForwardRefMapping;
393 for (std::map<std::pair<unsigned,unsigned>, Value*>::iterator
394 I = ForwardReferences.begin(), E = ForwardReferences.end();
395 I != E; ++I)
396 ForwardRefMapping[I->second] = getValue(I->first.first, I->first.second,
397 false);
398
399 for (Function::iterator BB = F->begin(), E = F->end(); BB != E; ++BB)
400 for (BasicBlock::iterator I = BB->begin(), E = BB->end(); I != E; ++I)
401 for (unsigned i = 0, e = I->getNumOperands(); i != e; ++i)
402 if (Argument *A = dyn_cast<Argument>(I->getOperand(i))) {
403 std::map<Value*, Value*>::iterator It = ForwardRefMapping.find(A);
404 if (It != ForwardRefMapping.end()) I->setOperand(i, It->second);
405 }
406
Chris Lattner8eb10ce2003-10-09 06:05:40 +0000407 while (!ForwardReferences.empty()) {
Chris Lattner35d2ca62003-10-09 22:39:30 +0000408 std::map<std::pair<unsigned,unsigned>, Value*>::iterator I =
409 ForwardReferences.begin();
Chris Lattner8eb10ce2003-10-09 06:05:40 +0000410 Value *PlaceHolder = I->second;
411 ForwardReferences.erase(I);
Chris Lattner00950542001-06-06 20:29:01 +0000412
Chris Lattner8eb10ce2003-10-09 06:05:40 +0000413 // Now that all the uses are gone, delete the placeholder...
414 // If we couldn't find a def (error case), then leak a little
415 // memory, because otherwise we can't remove all uses!
416 delete PlaceHolder;
Chris Lattner6e448022003-10-08 21:51:46 +0000417 }
Chris Lattner00950542001-06-06 20:29:01 +0000418
Misha Brukman12c29d12003-09-22 23:38:23 +0000419 // Clear out function-level types...
Chris Lattner6e5a0e42003-03-06 17:18:14 +0000420 FunctionTypeValues.clear();
Chris Lattnere4d71a12001-09-14 22:03:42 +0000421
Chris Lattner52e20b02003-03-19 20:54:26 +0000422 freeTable(Values);
Chris Lattner00950542001-06-06 20:29:01 +0000423}
424
Misha Brukman12c29d12003-09-22 23:38:23 +0000425void BytecodeParser::ParseModuleGlobalInfo(const unsigned char *&Buf,
426 const unsigned char *End) {
427 if (!FunctionSignatureList.empty())
428 throw std::string("Two ModuleGlobalInfo packets found!");
Chris Lattner00950542001-06-06 20:29:01 +0000429
Chris Lattner70cc3392001-09-10 07:58:01 +0000430 // Read global variables...
Chris Lattner7969dc22004-01-15 06:13:09 +0000431 unsigned VarType = read_vbr_uint(Buf, End);
Chris Lattner70cc3392001-09-10 07:58:01 +0000432 while (VarType != Type::VoidTyID) { // List is terminated by Void
Chris Lattnere3869c82003-04-16 21:16:05 +0000433 unsigned SlotNo;
434 GlobalValue::LinkageTypes Linkage;
435
Chris Lattnerc08912f2004-01-14 16:44:44 +0000436 unsigned LinkageID;
437 if (hasExtendedLinkageSpecs) {
438 // VarType Fields: bit0 = isConstant, bit1 = hasInitializer,
439 // bit2,3,4 = Linkage, bit4+ = slot#
440 SlotNo = VarType >> 5;
441 LinkageID = (VarType >> 2) & 7;
Chris Lattnere3869c82003-04-16 21:16:05 +0000442 } else {
443 // VarType Fields: bit0 = isConstant, bit1 = hasInitializer,
Chris Lattnerc08912f2004-01-14 16:44:44 +0000444 // bit2,3 = Linkage, bit4+ = slot#
445 SlotNo = VarType >> 4;
446 LinkageID = (VarType >> 2) & 3;
447 }
448 switch (LinkageID) {
449 default: assert(0 && "Unknown linkage type!");
450 case 0: Linkage = GlobalValue::ExternalLinkage; break;
451 case 1: Linkage = GlobalValue::WeakLinkage; break;
452 case 2: Linkage = GlobalValue::AppendingLinkage; break;
453 case 3: Linkage = GlobalValue::InternalLinkage; break;
454 case 4: Linkage = GlobalValue::LinkOnceLinkage; break;
Chris Lattnere3869c82003-04-16 21:16:05 +0000455 }
456
457 const Type *Ty = getType(SlotNo);
Chris Lattner927b1852003-10-09 20:22:47 +0000458 if (!isa<PointerType>(Ty))
Misha Brukman12c29d12003-09-22 23:38:23 +0000459 throw std::string("Global not pointer type! Ty = " +
460 Ty->getDescription());
Chris Lattner70cc3392001-09-10 07:58:01 +0000461
Chris Lattner52e20b02003-03-19 20:54:26 +0000462 const Type *ElTy = cast<PointerType>(Ty)->getElementType();
Chris Lattnerd70684f2001-09-18 04:01:05 +0000463
Chris Lattner70cc3392001-09-10 07:58:01 +0000464 // Create the global variable...
Chris Lattner4ad02e72003-04-16 20:28:45 +0000465 GlobalVariable *GV = new GlobalVariable(ElTy, VarType & 1, Linkage,
Chris Lattner52e20b02003-03-19 20:54:26 +0000466 0, "", TheModule);
Chris Lattner52e20b02003-03-19 20:54:26 +0000467 BCR_TRACE(2, "Global Variable of type: " << *Ty << "\n");
Chris Lattner29b789b2003-11-19 17:27:18 +0000468 insertValue(GV, SlotNo, ModuleValues);
Chris Lattner05950c32001-10-13 06:47:01 +0000469
Chris Lattner7969dc22004-01-15 06:13:09 +0000470 if (VarType & 2) // Does it have an initializer?
471 GlobalInits.push_back(std::make_pair(GV, read_vbr_uint(Buf, End)));
472 VarType = read_vbr_uint(Buf, End);
Chris Lattner70cc3392001-09-10 07:58:01 +0000473 }
474
Chris Lattner52e20b02003-03-19 20:54:26 +0000475 // Read the function objects for all of the functions that are coming
Chris Lattner7969dc22004-01-15 06:13:09 +0000476 unsigned FnSignature = read_vbr_uint(Buf, End);
Chris Lattner74734132002-08-17 22:01:27 +0000477 while (FnSignature != Type::VoidTyID) { // List is terminated by Void
478 const Type *Ty = getType(FnSignature);
Chris Lattner927b1852003-10-09 20:22:47 +0000479 if (!isa<PointerType>(Ty) ||
480 !isa<FunctionType>(cast<PointerType>(Ty)->getElementType()))
Misha Brukman12c29d12003-09-22 23:38:23 +0000481 throw std::string("Function not ptr to func type! Ty = " +
482 Ty->getDescription());
Chris Lattner8cdc6b72002-10-23 00:51:54 +0000483
Chris Lattner2a7b6ba2003-03-06 17:15:19 +0000484 // We create functions by passing the underlying FunctionType to create...
Chris Lattner7a176752001-12-04 00:03:30 +0000485 Ty = cast<PointerType>(Ty)->getElementType();
Chris Lattner00950542001-06-06 20:29:01 +0000486
Chris Lattner2a7b6ba2003-03-06 17:15:19 +0000487 // When the ModuleGlobalInfo section is read, we load the type of each
488 // function and the 'ModuleValues' slot that it lands in. We then load a
489 // placeholder into its slot to reserve it. When the function is loaded,
490 // this placeholder is replaced.
Chris Lattner00950542001-06-06 20:29:01 +0000491
492 // Insert the placeholder...
Chris Lattner4ad02e72003-04-16 20:28:45 +0000493 Function *Func = new Function(cast<FunctionType>(Ty),
494 GlobalValue::InternalLinkage, "", TheModule);
Chris Lattner29b789b2003-11-19 17:27:18 +0000495 insertValue(Func, FnSignature, ModuleValues);
Chris Lattner00950542001-06-06 20:29:01 +0000496
Chris Lattner52e20b02003-03-19 20:54:26 +0000497 // Keep track of this information in a list that is emptied as functions are
498 // loaded...
Chris Lattner00950542001-06-06 20:29:01 +0000499 //
Chris Lattner29b789b2003-11-19 17:27:18 +0000500 FunctionSignatureList.push_back(Func);
Chris Lattner52e20b02003-03-19 20:54:26 +0000501
Chris Lattner7969dc22004-01-15 06:13:09 +0000502 FnSignature = read_vbr_uint(Buf, End);
Chris Lattnerc9aa7df2002-03-29 03:51:11 +0000503 BCR_TRACE(2, "Function of type: " << Ty << "\n");
Chris Lattner00950542001-06-06 20:29:01 +0000504 }
505
Chris Lattner44d0eeb2004-01-15 17:55:01 +0000506 if (hasInconsistentModuleGlobalInfo)
507 align32(Buf, End);
Chris Lattner74734132002-08-17 22:01:27 +0000508
509 // Now that the function signature list is set up, reverse it so that we can
510 // remove elements efficiently from the back of the vector.
511 std::reverse(FunctionSignatureList.begin(), FunctionSignatureList.end());
Chris Lattner00950542001-06-06 20:29:01 +0000512
513 // This is for future proofing... in the future extra fields may be added that
514 // we don't understand, so we transparently ignore them.
515 //
516 Buf = End;
Chris Lattner00950542001-06-06 20:29:01 +0000517}
518
Misha Brukman12c29d12003-09-22 23:38:23 +0000519void BytecodeParser::ParseVersionInfo(const unsigned char *&Buf,
Chris Lattner12e64652003-05-22 18:08:30 +0000520 const unsigned char *EndBuf) {
Chris Lattner7969dc22004-01-15 06:13:09 +0000521 unsigned Version = read_vbr_uint(Buf, EndBuf);
Chris Lattner036b8aa2003-03-06 17:55:45 +0000522
523 // Unpack version number: low four bits are for flags, top bits = version
Chris Lattnerd445c6b2003-08-24 13:47:36 +0000524 Module::Endianness Endianness;
525 Module::PointerSize PointerSize;
526 Endianness = (Version & 1) ? Module::BigEndian : Module::LittleEndian;
527 PointerSize = (Version & 2) ? Module::Pointer64 : Module::Pointer32;
528
529 bool hasNoEndianness = Version & 4;
530 bool hasNoPointerSize = Version & 8;
531
532 RevisionNum = Version >> 4;
Chris Lattnere3869c82003-04-16 21:16:05 +0000533
534 // Default values for the current bytecode version
Chris Lattnercb7e2e22003-10-18 05:54:18 +0000535 hasExtendedLinkageSpecs = true;
536 hasOldStyleVarargs = false;
537 hasVarArgCallPadding = false;
Chris Lattner44d0eeb2004-01-15 17:55:01 +0000538 hasInconsistentModuleGlobalInfo = false;
Chris Lattnere3869c82003-04-16 21:16:05 +0000539 FirstDerivedTyID = 14;
Chris Lattner036b8aa2003-03-06 17:55:45 +0000540
541 switch (RevisionNum) {
Chris Lattnerc08912f2004-01-14 16:44:44 +0000542 case 2: // LLVM pre-1.0 release: will be deleted on the next rev
Chris Lattner9e893e82004-01-14 23:35:21 +0000543 // Version #2 only supported 4 linkage types. It didn't support weak
544 // linkage.
Chris Lattnercb7e2e22003-10-18 05:54:18 +0000545 hasExtendedLinkageSpecs = false;
546 hasOldStyleVarargs = true;
547 hasVarArgCallPadding = true;
Chris Lattner44d0eeb2004-01-15 17:55:01 +0000548 hasInconsistentModuleGlobalInfo = true;
549
Chris Lattnercb7e2e22003-10-18 05:54:18 +0000550 break;
Chris Lattnerc08912f2004-01-14 16:44:44 +0000551 case 0: // LLVM 1.0, 1.1 release version
Chris Lattnercb7e2e22003-10-18 05:54:18 +0000552 // Compared to rev #2, we added support for weak linkage, a more dense
553 // encoding, and better varargs support.
Chris Lattner9e893e82004-01-14 23:35:21 +0000554
555 // Base LLVM 1.0 bytecode format.
Chris Lattner44d0eeb2004-01-15 17:55:01 +0000556 hasInconsistentModuleGlobalInfo = true;
Chris Lattner036b8aa2003-03-06 17:55:45 +0000557 break;
Chris Lattnerc08912f2004-01-14 16:44:44 +0000558 case 1: // LLVM 1.2 release version
Chris Lattner9e893e82004-01-14 23:35:21 +0000559 // LLVM 1.2 added explicit support for emitting strings efficiently.
Chris Lattner44d0eeb2004-01-15 17:55:01 +0000560
561 // Also, it fixed the problem where the size of the ModuleGlobalInfo block
562 // included the size for the alignment at the end, where the rest of the
563 // blocks did not.
Chris Lattnerc08912f2004-01-14 16:44:44 +0000564 break;
565
Chris Lattner036b8aa2003-03-06 17:55:45 +0000566 default:
Misha Brukman12c29d12003-09-22 23:38:23 +0000567 throw std::string("Unknown bytecode version number!");
Chris Lattner036b8aa2003-03-06 17:55:45 +0000568 }
569
Chris Lattnerd445c6b2003-08-24 13:47:36 +0000570 if (hasNoEndianness) Endianness = Module::AnyEndianness;
571 if (hasNoPointerSize) PointerSize = Module::AnyPointerSize;
Chris Lattner76e38962003-04-22 18:15:10 +0000572
Chris Lattnerd445c6b2003-08-24 13:47:36 +0000573 TheModule->setEndianness(Endianness);
574 TheModule->setPointerSize(PointerSize);
Chris Lattner036b8aa2003-03-06 17:55:45 +0000575 BCR_TRACE(1, "Bytecode Rev = " << (unsigned)RevisionNum << "\n");
Chris Lattnerd445c6b2003-08-24 13:47:36 +0000576 BCR_TRACE(1, "Endianness/PointerSize = " << Endianness << ","
577 << PointerSize << "\n");
Chris Lattner036b8aa2003-03-06 17:55:45 +0000578}
579
Misha Brukman12c29d12003-09-22 23:38:23 +0000580void BytecodeParser::ParseModule(const unsigned char *Buf,
Chris Lattner12e64652003-05-22 18:08:30 +0000581 const unsigned char *EndBuf) {
Chris Lattner00950542001-06-06 20:29:01 +0000582 unsigned Type, Size;
Misha Brukman12c29d12003-09-22 23:38:23 +0000583 readBlock(Buf, EndBuf, Type, Size);
584 if (Type != BytecodeFormat::Module || Buf+Size != EndBuf)
585 throw std::string("Expected Module packet! B: "+
586 utostr((unsigned)(intptr_t)Buf) + ", S: "+utostr(Size)+
587 " E: "+utostr((unsigned)(intptr_t)EndBuf)); // Hrm, not a class?
Chris Lattner00950542001-06-06 20:29:01 +0000588
Chris Lattner1d670cc2001-09-07 16:37:43 +0000589 BCR_TRACE(0, "BLOCK BytecodeFormat::Module: {\n");
Chris Lattner74734132002-08-17 22:01:27 +0000590 FunctionSignatureList.clear(); // Just in case...
Chris Lattner00950542001-06-06 20:29:01 +0000591
592 // Read into instance variables...
Misha Brukman12c29d12003-09-22 23:38:23 +0000593 ParseVersionInfo(Buf, EndBuf);
Chris Lattner7969dc22004-01-15 06:13:09 +0000594 align32(Buf, EndBuf);
Chris Lattner00950542001-06-06 20:29:01 +0000595
Chris Lattner00950542001-06-06 20:29:01 +0000596 while (Buf < EndBuf) {
Chris Lattnerb6c46952003-03-06 17:03:28 +0000597 const unsigned char *OldBuf = Buf;
Misha Brukman12c29d12003-09-22 23:38:23 +0000598 readBlock(Buf, EndBuf, Type, Size);
Chris Lattner00950542001-06-06 20:29:01 +0000599 switch (Type) {
Chris Lattner52e20b02003-03-19 20:54:26 +0000600 case BytecodeFormat::GlobalTypePlane:
601 BCR_TRACE(1, "BLOCK BytecodeFormat::GlobalTypePlane: {\n");
Misha Brukman12c29d12003-09-22 23:38:23 +0000602 ParseGlobalTypes(Buf, Buf+Size);
Chris Lattner52e20b02003-03-19 20:54:26 +0000603 break;
604
605 case BytecodeFormat::ModuleGlobalInfo:
606 BCR_TRACE(1, "BLOCK BytecodeFormat::ModuleGlobalInfo: {\n");
Misha Brukman12c29d12003-09-22 23:38:23 +0000607 ParseModuleGlobalInfo(Buf, Buf+Size);
Chris Lattner52e20b02003-03-19 20:54:26 +0000608 break;
609
Chris Lattner1d670cc2001-09-07 16:37:43 +0000610 case BytecodeFormat::ConstantPool:
611 BCR_TRACE(1, "BLOCK BytecodeFormat::ConstantPool: {\n");
Misha Brukman12c29d12003-09-22 23:38:23 +0000612 ParseConstantPool(Buf, Buf+Size, ModuleValues, ModuleTypeValues);
Chris Lattner00950542001-06-06 20:29:01 +0000613 break;
614
Chris Lattnerc9aa7df2002-03-29 03:51:11 +0000615 case BytecodeFormat::Function: {
616 BCR_TRACE(1, "BLOCK BytecodeFormat::Function: {\n");
Misha Brukman12c29d12003-09-22 23:38:23 +0000617 ParseFunction(Buf, Buf+Size);
Chris Lattner00950542001-06-06 20:29:01 +0000618 break;
619 }
620
621 case BytecodeFormat::SymbolTable:
Chris Lattner1d670cc2001-09-07 16:37:43 +0000622 BCR_TRACE(1, "BLOCK BytecodeFormat::SymbolTable: {\n");
Chris Lattner4ee8ef22003-10-08 22:52:54 +0000623 ParseSymbolTable(Buf, Buf+Size, &TheModule->getSymbolTable(), 0);
Chris Lattner00950542001-06-06 20:29:01 +0000624 break;
Chris Lattner00950542001-06-06 20:29:01 +0000625 default:
Chris Lattner00950542001-06-06 20:29:01 +0000626 Buf += Size;
Misha Brukman12c29d12003-09-22 23:38:23 +0000627 if (OldBuf > Buf) throw std::string("Expected Module Block!");
Chris Lattner00950542001-06-06 20:29:01 +0000628 break;
629 }
Chris Lattner1d670cc2001-09-07 16:37:43 +0000630 BCR_TRACE(1, "} end block\n");
Chris Lattner7969dc22004-01-15 06:13:09 +0000631 align32(Buf, EndBuf);
Chris Lattner00950542001-06-06 20:29:01 +0000632 }
633
Chris Lattner52e20b02003-03-19 20:54:26 +0000634 // After the module constant pool has been read, we can safely initialize
635 // global variables...
636 while (!GlobalInits.empty()) {
637 GlobalVariable *GV = GlobalInits.back().first;
638 unsigned Slot = GlobalInits.back().second;
639 GlobalInits.pop_back();
640
641 // Look up the initializer value...
Chris Lattner29b789b2003-11-19 17:27:18 +0000642 // FIXME: Preserve this type ID!
643 unsigned TypeSlot = getTypeSlot(GV->getType()->getElementType());
Chris Lattner93361992004-01-15 18:45:25 +0000644 if (Constant *CV = getConstantValue(TypeSlot, Slot)) {
Misha Brukman12c29d12003-09-22 23:38:23 +0000645 if (GV->hasInitializer())
646 throw std::string("Global *already* has an initializer?!");
Chris Lattner93361992004-01-15 18:45:25 +0000647 GV->setInitializer(CV);
Chris Lattner52e20b02003-03-19 20:54:26 +0000648 } else
Misha Brukman12c29d12003-09-22 23:38:23 +0000649 throw std::string("Cannot find initializer value.");
Chris Lattner52e20b02003-03-19 20:54:26 +0000650 }
651
Misha Brukman12c29d12003-09-22 23:38:23 +0000652 if (!FunctionSignatureList.empty())
653 throw std::string("Function expected, but bytecode stream ended!");
Chris Lattner1d670cc2001-09-07 16:37:43 +0000654
655 BCR_TRACE(0, "} end block\n\n");
Chris Lattner00950542001-06-06 20:29:01 +0000656}
657
Chris Lattnercb7e2e22003-10-18 05:54:18 +0000658void BytecodeParser::ParseBytecode(const unsigned char *Buf, unsigned Length,
659 const std::string &ModuleID) {
Misha Brukmane0dd0d42003-09-23 16:15:29 +0000660
Misha Brukman12c29d12003-09-22 23:38:23 +0000661 unsigned char *EndBuf = (unsigned char*)(Buf + Length);
Misha Brukmane0dd0d42003-09-23 16:15:29 +0000662
Chris Lattner00950542001-06-06 20:29:01 +0000663 // Read and check signature...
Chris Lattner7969dc22004-01-15 06:13:09 +0000664 unsigned Sig = read(Buf, EndBuf);
665 if (Sig != ('l' | ('l' << 8) | ('v' << 16) | ('m' << 24)))
Misha Brukman12c29d12003-09-22 23:38:23 +0000666 throw std::string("Invalid bytecode signature!");
Chris Lattner00950542001-06-06 20:29:01 +0000667
Chris Lattner75f20532003-04-22 18:02:52 +0000668 TheModule = new Module(ModuleID);
Misha Brukman12c29d12003-09-22 23:38:23 +0000669 try {
Chris Lattnercb7e2e22003-10-18 05:54:18 +0000670 usesOldStyleVarargs = false;
Misha Brukman12c29d12003-09-22 23:38:23 +0000671 ParseModule(Buf, EndBuf);
672 } catch (std::string &Error) {
Chris Lattnera2602f32003-05-22 18:26:48 +0000673 freeState(); // Must destroy handles before deleting module!
Chris Lattner2a7b6ba2003-03-06 17:15:19 +0000674 delete TheModule;
675 TheModule = 0;
Chris Lattnerb0b7c0d2003-09-26 14:44:52 +0000676 throw;
Chris Lattner2a7b6ba2003-03-06 17:15:19 +0000677 }
Chris Lattner00950542001-06-06 20:29:01 +0000678}