aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lib/Analysis/DebugInfo.cpp4
-rw-r--r--lib/AsmParser/LLParser.cpp568
-rw-r--r--lib/Bitcode/Reader/BitcodeReader.cpp412
-rw-r--r--lib/Bitcode/Writer/BitcodeWriter.cpp274
-rw-r--r--lib/Bitcode/Writer/ValueEnumerator.cpp79
-rw-r--r--lib/CodeGen/DwarfEHPrepare.cpp4
-rw-r--r--lib/CodeGen/RegAllocPBQP.cpp6
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGISel.cpp140
-rw-r--r--lib/CodeGen/SimpleRegisterCoalescing.cpp134
-rw-r--r--lib/Support/APInt.cpp2
-rw-r--r--lib/Target/Alpha/AlphaCodeEmitter.cpp4
-rw-r--r--lib/Target/Alpha/AlphaISelLowering.cpp128
-rw-r--r--lib/Target/Blackfin/BlackfinISelLowering.cpp4
-rw-r--r--lib/Target/PowerPC/PPCCodeEmitter.cpp12
-rw-r--r--lib/Target/X86/X86ISelLowering.cpp20
-rw-r--r--lib/Transforms/IPO/MergeFunctions.cpp10
-rw-r--r--lib/Transforms/Scalar/GVN.cpp422
-rw-r--r--lib/VMCore/AsmWriter.cpp238
-rw-r--r--lib/VMCore/Instruction.cpp8
19 files changed, 1234 insertions, 1235 deletions
diff --git a/lib/Analysis/DebugInfo.cpp b/lib/Analysis/DebugInfo.cpp
index 5d275ddef2..a072161896 100644
--- a/lib/Analysis/DebugInfo.cpp
+++ b/lib/Analysis/DebugInfo.cpp
@@ -793,7 +793,7 @@ DILexicalBlock DIFactory::CreateLexicalBlock(DIDescriptor Context) {
/// CreateLocation - Creates a debug info location.
DILocation DIFactory::CreateLocation(unsigned LineNo, unsigned ColumnNo,
- DIScope S, DILocation OrigLoc) {
+ DIScope S, DILocation OrigLoc) {
Value *Elts[] = {
ConstantInt::get(Type::getInt32Ty(VMContext), LineNo),
ConstantInt::get(Type::getInt32Ty(VMContext), ColumnNo),
@@ -1218,7 +1218,7 @@ namespace llvm {
// If this location is already tracked then use it.
DebugLocTuple Tuple(Context, Loc.getLineNumber(),
- Loc.getColumnNumber());
+ Loc.getColumnNumber());
DenseMap<DebugLocTuple, unsigned>::iterator II
= DebugLocInfo.DebugIdMap.find(Tuple);
if (II != DebugLocInfo.DebugIdMap.end())
diff --git a/lib/AsmParser/LLParser.cpp b/lib/AsmParser/LLParser.cpp
index 295329bf97..0ecf8473c1 100644
--- a/lib/AsmParser/LLParser.cpp
+++ b/lib/AsmParser/LLParser.cpp
@@ -45,7 +45,7 @@ namespace llvm {
t_InlineAsm, // Value in StrVal/StrVal2/UIntVal.
t_Metadata // Value in MetadataVal.
} Kind;
-
+
LLParser::LocTy Loc;
unsigned UIntVal;
std::string StrVal, StrVal2;
@@ -77,27 +77,27 @@ bool LLParser::ValidateEndOfModule() {
return Error(ForwardRefTypeIDs.begin()->second.second,
"use of undefined type '%" +
utostr(ForwardRefTypeIDs.begin()->first) + "'");
-
+
if (!ForwardRefVals.empty())
return Error(ForwardRefVals.begin()->second.second,
"use of undefined value '@" + ForwardRefVals.begin()->first +
"'");
-
+
if (!ForwardRefValIDs.empty())
return Error(ForwardRefValIDs.begin()->second.second,
"use of undefined value '@" +
utostr(ForwardRefValIDs.begin()->first) + "'");
-
+
if (!ForwardRefMDNodes.empty())
return Error(ForwardRefMDNodes.begin()->second.second,
"use of undefined metadata '!" +
utostr(ForwardRefMDNodes.begin()->first) + "'");
-
+
// Look for intrinsic functions and CallInst that need to be upgraded
for (Module::iterator FI = M->begin(), FE = M->end(); FI != FE; )
UpgradeCallsToIntrinsic(FI++); // must be post-increment, as we remove
-
+
// Check debug info intrinsics.
CheckDebugInfoIntrinsics(M);
return false;
@@ -160,7 +160,7 @@ bool LLParser::ParseTopLevelEntities() {
return true;
break;
}
-
+
case lltok::kw_thread_local: // OptionalThreadLocal
case lltok::kw_addrspace: // OptionalAddrSpace
case lltok::kw_constant: // GlobalType
@@ -177,11 +177,11 @@ bool LLParser::ParseTopLevelEntities() {
bool LLParser::ParseModuleAsm() {
assert(Lex.getKind() == lltok::kw_module);
Lex.Lex();
-
- std::string AsmStr;
+
+ std::string AsmStr;
if (ParseToken(lltok::kw_asm, "expected 'module asm'") ||
ParseStringConstant(AsmStr)) return true;
-
+
const std::string &AsmSoFar = M->getModuleInlineAsm();
if (AsmSoFar.empty())
M->setModuleInlineAsm(AsmStr);
@@ -227,7 +227,7 @@ bool LLParser::ParseDepLibs() {
if (EatIfPresent(lltok::rsquare))
return false;
-
+
std::string Str;
if (ParseStringConstant(Str)) return true;
M->addLibrary(Str);
@@ -263,21 +263,21 @@ bool LLParser::ParseUnnamedType() {
PATypeHolder Ty(Type::getVoidTy(Context));
if (ParseType(Ty)) return true;
-
+
// See if this type was previously referenced.
std::map<unsigned, std::pair<PATypeHolder, LocTy> >::iterator
FI = ForwardRefTypeIDs.find(TypeID);
if (FI != ForwardRefTypeIDs.end()) {
if (FI->second.first.get() == Ty)
return Error(TypeLoc, "self referential type is invalid");
-
+
cast<DerivedType>(FI->second.first.get())->refineAbstractTypeTo(Ty);
Ty = FI->second.first.get();
ForwardRefTypeIDs.erase(FI);
}
-
+
NumberedTypes.push_back(Ty);
-
+
return false;
}
@@ -287,14 +287,14 @@ bool LLParser::ParseNamedType() {
std::string Name = Lex.getStrVal();
LocTy NameLoc = Lex.getLoc();
Lex.Lex(); // eat LocalVar.
-
+
PATypeHolder Ty(Type::getVoidTy(Context));
-
+
if (ParseToken(lltok::equal, "expected '=' after name") ||
ParseToken(lltok::kw_type, "expected 'type' after name") ||
ParseType(Ty))
return true;
-
+
// Set the type name, checking for conflicts as we do so.
bool AlreadyExists = M->addTypeName(Name, Ty);
if (!AlreadyExists) return false;
@@ -311,16 +311,16 @@ bool LLParser::ParseNamedType() {
Ty = FI->second.first.get();
ForwardRefTypes.erase(FI);
}
-
+
// Inserting a name that is already defined, get the existing name.
const Type *Existing = M->getTypeByName(Name);
assert(Existing && "Conflict but no matching type?!");
-
+
// Otherwise, this is an attempt to redefine a type. That's okay if
// the redefinition is identical to the original.
// FIXME: REMOVE REDEFINITIONS IN LLVM 3.0
if (Existing == Ty) return false;
-
+
// Any other kind of (non-equivalent) redefinition is an error.
return Error(NameLoc, "redefinition of type named '" + Name + "' of type '" +
Ty->getDescription() + "'");
@@ -332,7 +332,7 @@ bool LLParser::ParseNamedType() {
bool LLParser::ParseDeclare() {
assert(Lex.getKind() == lltok::kw_declare);
Lex.Lex();
-
+
Function *F;
return ParseFunctionHeader(F, false);
}
@@ -342,7 +342,7 @@ bool LLParser::ParseDeclare() {
bool LLParser::ParseDefine() {
assert(Lex.getKind() == lltok::kw_define);
Lex.Lex();
-
+
Function *F;
return ParseFunctionHeader(F, true) ||
ParseFunctionBody(*F);
@@ -390,7 +390,7 @@ bool LLParser::ParseUnnamedGlobal() {
if (ParseOptionalLinkage(Linkage, HasLinkage) ||
ParseOptionalVisibility(Visibility))
return true;
-
+
if (HasLinkage || Lex.getKind() != lltok::kw_alias)
return ParseGlobal(Name, NameLoc, Linkage, HasLinkage, Visibility);
return ParseAlias(Name, NameLoc, Visibility);
@@ -404,14 +404,14 @@ bool LLParser::ParseNamedGlobal() {
LocTy NameLoc = Lex.getLoc();
std::string Name = Lex.getStrVal();
Lex.Lex();
-
+
bool HasLinkage;
unsigned Linkage, Visibility;
if (ParseToken(lltok::equal, "expected '=' in global variable") ||
ParseOptionalLinkage(Linkage, HasLinkage) ||
ParseOptionalVisibility(Visibility))
return true;
-
+
if (HasLinkage || Lex.getKind() != lltok::kw_alias)
return ParseGlobal(Name, NameLoc, Linkage, HasLinkage, Visibility);
return ParseAlias(Name, NameLoc, Visibility);
@@ -432,7 +432,7 @@ bool LLParser::ParseMDNode(MetadataBase *&Node) {
// !{ ..., !42, ... }
unsigned MID = 0;
if (ParseUInt32(MID)) return true;
-
+
// Check existing MDNode.
std::map<unsigned, MetadataBase *>::iterator I = MetadataCache.find(MID);
if (I != MetadataCache.end()) {
@@ -456,7 +456,7 @@ bool LLParser::ParseMDNode(MetadataBase *&Node) {
ForwardRefMDNodes[MID] = std::make_pair(FwdNode, Lex.getLoc());
Node = FwdNode;
return false;
-}
+}
///ParseNamedMetadata:
/// !foo = !{ !1, !2 }
@@ -493,7 +493,7 @@ bool LLParser::ParseNamedMetadata() {
}
/// ParseStandaloneMetadata:
-/// !42 = !{...}
+/// !42 = !{...}
bool LLParser::ParseStandaloneMetadata() {
assert(Lex.getKind() == lltok::Metadata);
Lex.Lex();
@@ -509,7 +509,7 @@ bool LLParser::ParseStandaloneMetadata() {
PATypeHolder Ty(Type::getVoidTy(Context));
if (ParseType(Ty, TyLoc))
return true;
-
+
if (Lex.getKind() != lltok::Metadata)
return TokError("Expected metadata here");
@@ -518,7 +518,7 @@ bool LLParser::ParseStandaloneMetadata() {
return TokError("Expected '{' here");
SmallVector<Value *, 16> Elts;
- if (ParseMDNodeVector(Elts)
+ if (ParseMDNodeVector(Elts)
|| ParseToken(lltok::rbrace, "expected end of metadata node"))
return true;
@@ -560,7 +560,7 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc,
Linkage != GlobalValue::PrivateLinkage &&
Linkage != GlobalValue::LinkerPrivateLinkage)
return Error(LinkageLoc, "invalid linkage type for alias");
-
+
Constant *Aliasee;
LocTy AliaseeLoc = Lex.getLoc();
if (Lex.getKind() != lltok::kw_bitcast &&
@@ -574,7 +574,7 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc,
return Error(AliaseeLoc, "invalid aliasee");
Aliasee = ID.ConstantVal;
}
-
+
if (!isa<PointerType>(Aliasee->getType()))
return Error(AliaseeLoc, "alias must have pointer type");
@@ -583,7 +583,7 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc,
(GlobalValue::LinkageTypes)Linkage, Name,
Aliasee);
GA->setVisibility((GlobalValue::VisibilityTypes)Visibility);
-
+
// See if this value already exists in the symbol table. If so, it is either
// a redefinition or a definition of a forward reference.
if (GlobalValue *Val =
@@ -600,18 +600,18 @@ bool LLParser::ParseAlias(const std::string &Name, LocTy NameLoc,
if (Val->getType() != GA->getType())
return Error(NameLoc,
"forward reference and definition of alias have different types");
-
+
// If they agree, just RAUW the old value with the alias and remove the
// forward ref info.
Val->replaceAllUsesWith(GA);
Val->eraseFromParent();
ForwardRefVals.erase(I);
}
-
+
// Insert into the module, we know its name won't collide now.
M->getAliasList().push_back(GA);
assert(GA->getNameStr() == Name && "Should not be a name conflict!");
-
+
return false;
}
@@ -629,14 +629,14 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
unsigned AddrSpace;
bool ThreadLocal, IsConstant;
LocTy TyLoc;
-
+
PATypeHolder Ty(Type::getVoidTy(Context));
if (ParseOptionalToken(lltok::kw_thread_local, ThreadLocal) ||
ParseOptionalAddrSpace(AddrSpace) ||
ParseGlobalType(IsConstant) ||
ParseType(Ty, TyLoc))
return true;
-
+
// If the linkage is specified and is external, then no initializer is
// present.
Constant *Init = 0;
@@ -649,7 +649,7 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
if (isa<FunctionType>(Ty) || Ty == Type::getLabelTy(Context))
return Error(TyLoc, "invalid type for global variable");
-
+
GlobalVariable *GV = 0;
// See if the global was forward referenced, if so, use the global.
@@ -667,20 +667,20 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
}
if (GV == 0) {
- GV = new GlobalVariable(*M, Ty, false, GlobalValue::ExternalLinkage, 0,
+ GV = new GlobalVariable(*M, Ty, false, GlobalValue::ExternalLinkage, 0,
Name, 0, false, AddrSpace);
} else {
if (GV->getType()->getElementType() != Ty)
return Error(TyLoc,
"forward reference and definition of global have different types");
-
+
// Move the forward-reference to the correct spot in the module.
M->getGlobalList().splice(M->global_end(), M->getGlobalList(), GV);
}
if (Name.empty())
NumberedVals.push_back(GV);
-
+
// Set the parsed properties on the global.
if (Init)
GV->setInitializer(Init);
@@ -688,11 +688,11 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
GV->setLinkage((GlobalValue::LinkageTypes)Linkage);
GV->setVisibility((GlobalValue::VisibilityTypes)Visibility);
GV->setThreadLocal(ThreadLocal);
-
+
// Parse attributes on the global.
while (Lex.getKind() == lltok::comma) {
Lex.Lex();
-
+
if (Lex.getKind() == lltok::kw_section) {
Lex.Lex();
GV->setSection(Lex.getStrVal());
@@ -706,7 +706,7 @@ bool LLParser::ParseGlobal(const std::string &Name, LocTy NameLoc,
TokError("unknown global variable property!");
}
}
-
+
return false;
}
@@ -725,11 +725,11 @@ GlobalValue *LLParser::GetGlobalVal(const std::string &Name, const Type *Ty,
Error(Loc, "global variable reference must have pointer type");
return 0;
}
-
+
// Look this name up in the normal function symbol table.
GlobalValue *Val =
cast_or_null<GlobalValue>(M->getValueSymbolTable().lookup(Name));
-
+
// If this is a forward reference for the value, see if we already created a
// forward ref record.
if (Val == 0) {
@@ -738,7 +738,7 @@ GlobalValue *LLParser::GetGlobalVal(const std::string &Name, const Type *Ty,
if (I != ForwardRefVals.end())
Val = I->second.first;
}
-
+
// If we have the value in the symbol table or fwd-ref table, return it.
if (Val) {
if (Val->getType() == Ty) return Val;
@@ -746,7 +746,7 @@ GlobalValue *LLParser::GetGlobalVal(const std::string &Name, const Type *Ty,
Val->getType()->getDescription() + "'");
return 0;
}
-
+
// Otherwise, create a new forward reference for this value and remember it.
GlobalValue *FwdVal;
if (const FunctionType *FT = dyn_cast<FunctionType>(PTy->getElementType())) {
@@ -755,13 +755,13 @@ GlobalValue *LLParser::GetGlobalVal(const std::string &Name, const Type *Ty,
Error(Loc, "function may not return opaque type");
return 0;
}
-
+
FwdVal = Function::Create(FT, GlobalValue::ExternalWeakLinkage, Name, M);
} else {
FwdVal = new GlobalVariable(*M, PTy->getElementType(), false,
GlobalValue::ExternalWeakLinkage, 0, Name);
}
-
+
ForwardRefVals[Name] = std::make_pair(FwdVal, Loc);
return FwdVal;
}
@@ -772,9 +772,9 @@ GlobalValue *LLParser::GetGlobalVal(unsigned ID, const Type *Ty, LocTy Loc) {
Error(Loc, "global variable reference must have pointer type");
return 0;
}
-
+
GlobalValue *Val = ID < NumberedVals.size() ? NumberedVals[ID] : 0;
-
+
// If this is a forward reference for the value, see if we already created a
// forward ref record.
if (Val == 0) {
@@ -783,7 +783,7 @@ GlobalValue *LLParser::GetGlobalVal(unsigned ID, const Type *Ty, LocTy Loc) {
if (I != ForwardRefValIDs.end())
Val = I->second.first;
}
-
+
// If we have the value in the symbol table or fwd-ref table, return it.
if (Val) {
if (Val->getType() == Ty) return Val;
@@ -791,7 +791,7 @@ GlobalValue *LLParser::GetGlobalVal(unsigned ID, const Type *Ty, LocTy Loc) {
Val->getType()->getDescription() + "'");
return 0;
}
-
+
// Otherwise, create a new forward reference for this value and remember it.
GlobalValue *FwdVal;
if (const FunctionType *FT = dyn_cast<FunctionType>(PTy->getElementType())) {
@@ -805,7 +805,7 @@ GlobalValue *LLParser::GetGlobalVal(unsigned ID, const Type *Ty, LocTy Loc) {
FwdVal = new GlobalVariable(*M, PTy->getElementType(), false,
GlobalValue::ExternalWeakLinkage, 0, "");
}
-
+
ForwardRefValIDs[ID] = std::make_pair(FwdVal, Loc);
return FwdVal;
}
@@ -858,7 +858,7 @@ bool LLParser::ParseOptionalAddrSpace(unsigned &AddrSpace) {
return ParseToken(lltok::lparen, "expected '(' in address space") ||
ParseUInt32(AddrSpace) ||
ParseToken(lltok::rparen, "expected ')' in address space");
-}
+}
/// ParseOptionalAttrs - Parse a potentially empty attribute list. AttrKind
/// indicates what kind of attribute list this is: 0: function arg, 1: result,
@@ -867,7 +867,7 @@ bool LLParser::ParseOptionalAddrSpace(unsigned &AddrSpace) {
bool LLParser::ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind) {
Attrs = Attribute::None;
LocTy AttrLoc = Lex.getLoc();
-
+
while (1) {
switch (Lex.getKind()) {
case lltok::kw_sext:
@@ -888,10 +888,10 @@ bool LLParser::ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind) {
default: // End of attributes.
if (AttrKind != 2 && (Attrs & Attribute::FunctionOnly))
return Error(AttrLoc, "invalid use of function-only attribute");
-
+
if (AttrKind != 0 && AttrKind != 3 && (Attrs & Attribute::ParameterOnly))
return Error(AttrLoc, "invalid use of parameter-only attribute");
-
+
return false;
case lltok::kw_zeroext: Attrs |= Attribute::ZExt; break;
case lltok::kw_signext: Attrs |= Attribute::SExt; break;
@@ -915,7 +915,7 @@ bool LLParser::ParseOptionalAttrs(unsigned &Attrs, unsigned AttrKind) {
case lltok::kw_noredzone: Attrs |= Attribute::NoRedZone; break;
case lltok::kw_noimplicitfloat: Attrs |= Attribute::NoImplicitFloat; break;
case lltok::kw_naked: Attrs |= Attribute::Naked; break;
-
+
case lltok::kw_align: {
unsigned Alignment;
if (ParseOptionalAlignment(Alignment))
@@ -974,7 +974,7 @@ bool LLParser::ParseOptionalLinkage(unsigned &Res, bool &HasLinkage) {
/// ::= 'default'
/// ::= 'hidden'
/// ::= 'protected'
-///
+///
bool LLParser::ParseOptionalVisibility(unsigned &Res) {
switch (Lex.getKind()) {
default: Res = GlobalValue::DefaultVisibility; return false;
@@ -1020,7 +1020,7 @@ bool LLParser::ParseOptionalCallingConv(CallingConv::ID &CC) {
}
break;
}
-
+
Lex.Lex();
return false;
}
@@ -1037,13 +1037,13 @@ bool LLParser::ParseOptionalDbgInfo() {
Lex.Lex();
MetadataBase *Node;
if (ParseMDNode(Node)) return true;
-
+
Metadata &TheMetadata = M->getContext().getMetadata();
unsigned MDDbgKind = TheMetadata.getMDKind("dbg");
if (!MDDbgKind)
MDDbgKind = TheMetadata.RegisterMDKind("dbg");
MDsOnInst.push_back(std::make_pair(MDDbgKind, cast<MDNode>(Node)));
-
+
return false;
}
@@ -1074,7 +1074,7 @@ bool LLParser::ParseOptionalInfo(unsigned &Alignment) {
} else
return true;
} while (EatIfPresent(lltok::comma));
-
+
return false;
}
@@ -1084,13 +1084,13 @@ bool LLParser::ParseOptionalInfo(unsigned &Alignment) {
bool LLParser::ParseIndexList(SmallVectorImpl<unsigned> &Indices) {
if (Lex.getKind() != lltok::comma)
return TokError("expected ',' as start of index list");
-
+
while (EatIfPresent(lltok::comma)) {
unsigned Idx;
if (ParseUInt32(Idx)) return true;
Indices.push_back(Idx);
}
-
+
return false;
}
@@ -1102,14 +1102,14 @@ bool LLParser::ParseIndexList(SmallVectorImpl<unsigned> &Indices) {
bool LLParser::ParseType(PATypeHolder &Result, bool AllowVoid) {
LocTy TypeLoc = Lex.getLoc();
if (ParseTypeRec(Result)) return true;
-
+
// Verify no unresolved uprefs.
if (!UpRefs.empty())
return Error(UpRefs.back().Loc, "invalid unresolved type up reference");
-
+
if (!AllowVoid && Result.get() == Type::getVoidTy(Context))
return Error(TypeLoc, "void type only allowed for function results");
-
+
return false;
}
@@ -1124,26 +1124,26 @@ PATypeHolder LLParser::HandleUpRefs(const Type *ty) {
// If Ty isn't abstract, or if there are no up-references in it, then there is
// nothing to resolve here.
if (!ty->isAbstract() || UpRefs.empty()) return ty;
-
+
PATypeHolder Ty(ty);
#if 0
errs() << "Type '" << Ty->getDescription()
<< "' newly formed. Resolving upreferences.\n"
<< UpRefs.size() << " upreferences active!\n";
#endif
-
+
// If we find any resolvable upreferences (i.e., those whose NestingLevel goes
// to zero), we resolve them all together before we resolve them to Ty. At
// the end of the loop, if there is anything to resolve to Ty, it will be in
// this variable.
OpaqueType *TypeToResolve = 0;
-
+
for (unsigned i = 0; i != UpRefs.size(); ++i) {
// Determine if 'Ty' directly contains this up-references 'LastContainedTy'.
bool ContainsType =
std::find(Ty->subtype_begin(), Ty->subtype_end(),
UpRefs[i].LastContainedTy) != Ty->subtype_end();
-
+
#if 0
errs() << " UR#" << i << " - TypeContains(" << Ty->getDescription() << ", "
<< UpRefs[i].LastContainedTy->getDescription() << ") = "
@@ -1152,15 +1152,15 @@ PATypeHolder LLParser::HandleUpRefs(const Type *ty) {
#endif
if (!ContainsType)
continue;
-
+
// Decrement level of upreference
unsigned Level = --UpRefs[i].NestingLevel;
UpRefs[i].LastContainedTy = Ty;
-
+
// If the Up-reference has a non-zero level, it shouldn't be resolved yet.
if (Level != 0)
continue;
-
+
#if 0
errs() << " * Resolving upreference for " << UpRefs[i].UpRefTy << "\n";
#endif
@@ -1171,10 +1171,10 @@ PATypeHolder LLParser::HandleUpRefs(const Type *ty) {
UpRefs.erase(UpRefs.begin()+i); // Remove from upreference list.
--i; // Do not skip the next element.
}
-
+
if (TypeToResolve)
TypeToResolve->refineAbstractTypeTo(Ty);
-
+
return Ty;
}
@@ -1188,7 +1188,7 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) {
case lltok::Type:
// TypeRec ::= 'float' | 'void' (etc)
Result = Lex.getTyVal();
- Lex.Lex();
+ Lex.Lex();
break;
case lltok::kw_opaque:
// TypeRec ::= 'opaque'
@@ -1230,7 +1230,7 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) {
}
Lex.Lex();
break;
-
+
case lltok::LocalVarID:
// TypeRec ::= %4
if (Lex.getUIntVal() < NumberedTypes.size())
@@ -1260,12 +1260,12 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) {
break;
}
}
-
- // Parse the type suffixes.
+
+ // Parse the type suffixes.
while (1) {
switch (Lex.getKind()) {
// End of type.
- default: return false;
+ default: return false;
// TypeRec ::= TypeRec '*'
case lltok::star:
@@ -1295,7 +1295,7 @@ bool LLParser::ParseTypeRec(PATypeHolder &Result) {
Result = HandleUpRefs(PointerType::get(Result.get(), AddrSpace));
break;
}
-
+
/// Types '(' ArgTypeListI ')' OptFuncAttrs
case lltok::lparen:
if (ParseFunctionType(Result))
@@ -1314,13 +1314,13 @@ bool LLParser::ParseParameterList(SmallVectorImpl<ParamInfo> &ArgList,
PerFunctionState &PFS) {
if (ParseToken(lltok::lparen, "expected '(' in call"))
return true;
-
+
while (Lex.getKind() != lltok::rparen) {
// If this isn't the first argument, we need a comma.
if (!ArgList.empty() &&
ParseToken(lltok::comma, "expected ',' in argument list"))
return true;
-
+
// Parse the argument.
LocTy ArgLoc;
PATypeHolder ArgTy(Type::getVoidTy(Context));
@@ -1356,7 +1356,7 @@ bool LLParser::ParseArgumentList(std::vector<ArgInfo> &ArgList,
isVarArg = false;
assert(Lex.getKind() == lltok::lparen);
Lex.Lex(); // eat the (.
-
+
if (Lex.getKind() == lltok::rparen) {
// empty
} else if (Lex.getKind() == lltok::dotdotdot) {
@@ -1367,16 +1367,16 @@ bool LLParser::ParseArgumentList(std::vector<ArgInfo> &ArgList,
PATypeHolder ArgTy(Type::getVoidTy(Context));
unsigned Attrs;
std::string Name;
-
+
// If we're parsing a type, use ParseTypeRec, because we allow recursive
// types (such as a function returning a pointer to itself). If parsing a
// function prototype, we require fully resolved types.
if ((inType ? ParseTypeRec(ArgTy) : ParseType(ArgTy)) ||
ParseOptionalAttrs(Attrs, 0)) return true;
-
+
if (ArgTy == Type::getVoidTy(Context))
return Error(TypeLoc, "argument can not have void type");
-
+
if (Lex.getKind() == lltok::LocalVar ||
Lex.getKind() == lltok::StringConstant) { // FIXME: REMOVE IN LLVM 3.0
Name = Lex.getStrVal();
@@ -1385,16 +1385,16 @@ bool LLParser::ParseArgumentList(std::vector<ArgInfo> &ArgList,
if (!FunctionType::isValidArgumentType(ArgTy))
return Error(TypeLoc, "invalid type for function argument");
-
+
ArgList.push_back(ArgInfo(TypeLoc, ArgTy, Attrs, Name));
-
+
while (EatIfPresent(lltok::comma)) {
// Handle ... at end of arg list.
if (EatIfPresent(lltok::dotdotdot)) {
isVarArg = true;
break;
}
-
+
// Otherwise must be an argument type.
TypeLoc = Lex.getLoc();
if ((inType ? ParseTypeRec(ArgTy) : ParseType(ArgTy)) ||
@@ -1413,14 +1413,14 @@ bool LLParser::ParseArgumentList(std::vector<ArgInfo> &ArgList,
if (!ArgTy->isFirstClassType() && !isa<OpaqueType>(ArgTy))
return Error(TypeLoc, "invalid type for function argument");
-
+
ArgList.push_back(ArgInfo(TypeLoc, ArgTy, Attrs, Name));
}
}
-
+
return ParseToken(lltok::rparen, "expected ')' at end of argument list");
}
-
+
/// ParseFunctionType
/// ::= Type ArgumentList OptionalAttrs
bool LLParser::ParseFunctionType(PATypeHolder &Result) {
@@ -1428,7 +1428,7 @@ bool LLParser::ParseFunctionType(PATypeHolder &Result) {
if (!FunctionType::isValidReturnType(Result))
return TokError("invalid function return type");
-
+
std::vector<ArgInfo> ArgList;
bool isVarArg;
unsigned Attrs;
@@ -1437,7 +1437,7 @@ bool LLParser::ParseFunctionType(PATypeHolder &Result) {
// FIXME: Remove in LLVM 3.0
ParseOptionalAttrs(Attrs, 2))
return true;
-
+
// Reject names on the arguments lists.
for (unsigned i = 0, e = ArgList.size(); i != e; ++i) {
if (!ArgList[i].Name.empty())
@@ -1448,11 +1448,11 @@ bool LLParser::ParseFunctionType(PATypeHolder &Result) {
// FIXME: REJECT ATTRIBUTES ON FUNCTION TYPES in LLVM 3.0
}
}
-
+
std::vector<const Type*> ArgListTy;
for (unsigned i = 0, e = ArgList.size(); i != e; ++i)
ArgListTy.push_back(ArgList[i].Type);
-
+
Result = HandleUpRefs(FunctionType::get(Result.get(),
ArgListTy, isVarArg));
return false;
@@ -1467,7 +1467,7 @@ bool LLParser::ParseFunctionType(PATypeHolder &Result) {
bool LLParser::ParseStructType(PATypeHolder &Result, bool Packed) {
assert(Lex.getKind() == lltok::lbrace);
Lex.Lex(); // Consume the '{'
-
+
if (EatIfPresent(lltok::rbrace)) {
Result = StructType::get(Context, Packed);
return false;
@@ -1477,27 +1477,27 @@ bool LLParser::ParseStructType(PATypeHolder &Result, bool Packed) {
LocTy EltTyLoc = Lex.getLoc();
if (ParseTypeRec(Result)) return true;
ParamsList.push_back(Result);
-
+
if (Result == Type::getVoidTy(Context))
return Error(EltTyLoc, "struct element can not have void type");
if (!StructType::isValidElementType(Result))
return Error(EltTyLoc, "invalid element type for struct");
-
+
while (EatIfPresent(lltok::comma)) {
EltTyLoc = Lex.getLoc();
if (ParseTypeRec(Result)) return true;
-
+
if (Result == Type::getVoidTy(Context))
return Error(EltTyLoc, "struct element can not have void type");
if (!StructType::isValidElementType(Result))
return Error(EltTyLoc, "invalid element type for struct");
-
+
ParamsList.push_back(Result);
}
-
+
if (ParseToken(lltok::rbrace, "expected '}' at end of struct"))
return true;
-
+
std::vector<const Type*> ParamsListTy;
for (unsigned i = 0, e = ParamsList.size(); i != e; ++i)
ParamsListTy.push_back(ParamsList[i].get());
@@ -1507,32 +1507,32 @@ bool LLParser::ParseStructType(PATypeHolder &Result, bool Packed) {
/// ParseArrayVectorType - Parse an array or vector type, assuming the first
/// token has already been consumed.
-/// TypeRec
+/// TypeRec
/// ::= '[' APSINTVAL 'x' Types ']'
/// ::= '<' APSINTVAL 'x' Types '>'
bool LLParser::ParseArrayVectorType(PATypeHolder &Result, bool isVector) {
if (Lex.getKind() != lltok::APSInt || Lex.getAPSIntVal().isSigned() ||
Lex.getAPSIntVal().getBitWidth() > 64)
return TokError("expected number in address space");
-
+
LocTy SizeLoc = Lex.getLoc();
uint64_t Size = Lex.getAPSIntVal().getZExtValue();
Lex.Lex();
-
+
if (ParseToken(lltok::kw_x, "expected 'x' after element count"))
return true;
LocTy TypeLoc = Lex.getLoc();
PATypeHolder EltTy(Type::getVoidTy(Context));
if (ParseTypeRec(EltTy)) return true;
-
+
if (EltTy == Type::getVoidTy(Context))
return Error(TypeLoc, "array and vector element type cannot be void");
if (ParseToken(isVector ? lltok::greater : lltok::rsquare,
"expected end of sequential type"))
return true;
-
+
if (isVector) {
if (Size == 0)
return Error(SizeLoc, "zero element vector is illegal");
@@ -1573,7 +1573,7 @@ LLParser::PerFunctionState::~PerFunctionState() {
delete I->second.first;
I->second.first = 0;
}
-
+
for (std::map<unsigned, std::pair<Value*, LocTy> >::iterator
I = ForwardRefValIDs.begin(), E = ForwardRefValIDs.end(); I != E; ++I)
if (!isa<BasicBlock>(I->second.first)) {
@@ -1604,7 +1604,7 @@ Value *LLParser::PerFunctionState::GetVal(const std::string &Name,
const Type *Ty, LocTy Loc) {
// Look this name up in the normal function symbol table.
Value *Val = F.getValueSymbolTable().lookup(Name);
-
+
// If this is a forward reference for the value, see if we already created a
// forward ref record.
if (Val == 0) {
@@ -1613,7 +1613,7 @@ Value *LLParser::PerFunctionState::GetVal(const std::string &Name,
if (I != ForwardRefVals.end())
Val = I->second.first;
}
-
+
// If we have the value in the symbol table or fwd-ref table, return it.
if (Val) {
if (Val->getType() == Ty) return Val;
@@ -1624,21 +1624,21 @@ Value *LLParser::PerFunctionState::GetVal(const std::string &Name,
Val->getType()->getDescription() + "'");
return 0;
}
-
+
// Don't make placeholders with invalid type.
if (!Ty->isFirstClassType() && !isa<OpaqueType>(Ty) &&
Ty != Type::getLabelTy(F.getContext())) {
P.Error(Loc, "invalid use of a non-first-class type");
return 0;
}
-
+
// Otherwise, create a new forward reference for this value and remember it.
Value *FwdVal;
- if (Ty == Type::getLabelTy(F.getContext()))