From: Chris Lattner Date: Wed, 19 Nov 2003 17:21:11 +0000 (+0000) Subject: Minor efficiency improvements, finegrainify namespacification X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=8eb49936ae8504f185d0e02eb1fed0a2196d66bd;p=oota-llvm.git Minor efficiency improvements, finegrainify namespacification git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@10084 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Bytecode/Reader/InstructionReader.cpp b/lib/Bytecode/Reader/InstructionReader.cpp index ec8944e7a87..3ca00f35cc6 100644 --- a/lib/Bytecode/Reader/InstructionReader.cpp +++ b/lib/Bytecode/Reader/InstructionReader.cpp @@ -21,8 +21,7 @@ #include "llvm/iPHINode.h" #include "llvm/iOther.h" #include "llvm/Module.h" - -namespace llvm { +using namespace llvm; namespace { struct RawInst { // The raw fields out of the bytecode stream... @@ -234,7 +233,7 @@ void BytecodeParser::ParseInstruction(const unsigned char *&Buf, for (unsigned i = 1, e = Args.size(); i != e; ++i) { if (It == PL.end()) throw std::string("Invalid call instruction!"); - Params.push_back(getValue(*It++, Args[i])); + Params.push_back(getValue(getTypeSlot(*It++), Args[i])); } if (It != PL.end()) throw std::string("Invalid call instruction!"); } else { @@ -247,7 +246,7 @@ void BytecodeParser::ParseInstruction(const unsigned char *&Buf, // Read all of the fixed arguments for (unsigned i = 0, e = FTy->getNumParams(); i != e; ++i) - Params.push_back(getValue(FTy->getParamType(i), Args[i])); + Params.push_back(getValue(getTypeSlot(FTy->getParamType(i)),Args[i])); FirstVariableOperand = FTy->getNumParams(); } else { @@ -286,7 +285,7 @@ void BytecodeParser::ParseInstruction(const unsigned char *&Buf, FunctionType::ParamTypes::const_iterator It = PL.begin(); for (unsigned i = 3, e = Args.size(); i != e; ++i) { if (It == PL.end()) throw std::string("Invalid invoke instruction!"); - Params.push_back(getValue(*It++, Args[i])); + Params.push_back(getValue(getTypeSlot(*It++), Args[i])); } if (It != PL.end()) throw std::string("Invalid invoke instruction!"); } else { @@ -299,7 +298,8 @@ void BytecodeParser::ParseInstruction(const unsigned char *&Buf, FirstVariableArgument = FTy->getNumParams()+2; for (unsigned i = 2; i != FirstVariableArgument; ++i) - Params.push_back(getValue(FTy->getParamType(i-2), Args[i])); + Params.push_back(getValue(getTypeSlot(FTy->getParamType(i-2)), + Args[i])); } else { if (Args.size() < 4) throw std::string("Invalid invoke instruction!"); @@ -354,7 +354,7 @@ void BytecodeParser::ParseInstruction(const unsigned char *&Buf, for (unsigned i = 1, e = Args.size(); i != e; ++i) { const CompositeType *TopTy = dyn_cast_or_null(NextTy); if (!TopTy) throw std::string("Invalid getelementptr instruction!"); - Idx.push_back(getValue(TopTy->getIndexType(), Args[i])); + Idx.push_back(getValue(TopTy->getIndexType()->getPrimitiveID(), Args[i])); NextTy = GetElementPtrInst::getIndexedType(InstTy, Idx, true); } @@ -376,7 +376,8 @@ void BytecodeParser::ParseInstruction(const unsigned char *&Buf, Value *Ptr = getValue(RI.Type, Args[1]); const Type *ValTy = cast(Ptr->getType())->getElementType(); - Result = new StoreInst(getValue(ValTy, Args[0]), Ptr, RI.Opcode == 63); + Result = new StoreInst(getValue(getTypeSlot(ValTy), Args[0]), Ptr, + RI.Opcode == 63); break; } case Instruction::Unwind: @@ -385,9 +386,13 @@ void BytecodeParser::ParseInstruction(const unsigned char *&Buf, break; } // end switch(RI.Opcode) - insertValue(Result, Values); + unsigned TypeSlot; + if (Result->getType() == InstTy) + TypeSlot = RI.Type; + else + TypeSlot = getTypeSlot(Result->getType()); + + insertValue(Result, TypeSlot, Values); BB->getInstList().push_back(Result); BCR_TRACE(4, *Result); } - -} // End llvm namespace