Changes in directory llvm/lib/Bytecode/Reader:
Reader.cpp updated: 1.245 -> 1.246 Reader.h updated: 1.51 -> 1.52 --- Log message: For PR1146: http://llvm.org/PR1146 : Use ParamAttrsList for writing parameter attributes. Since they are sparse now, we also write them sparsely (saves a few bytes). Unfortunately, this is a bytecode file format change. --- Diffs of the changes: (+26 -8) Reader.cpp | 30 ++++++++++++++++++++++-------- Reader.h | 4 ++++ 2 files changed, 26 insertions(+), 8 deletions(-) Index: llvm/lib/Bytecode/Reader/Reader.cpp diff -u llvm/lib/Bytecode/Reader/Reader.cpp:1.245 llvm/lib/Bytecode/Reader/Reader.cpp:1.246 --- llvm/lib/Bytecode/Reader/Reader.cpp:1.245 Sun Apr 8 18:58:41 2007 +++ llvm/lib/Bytecode/Reader/Reader.cpp Mon Apr 9 01:14:31 2007 @@ -23,6 +23,7 @@ #include "llvm/Constants.h" #include "llvm/InlineAsm.h" #include "llvm/Instructions.h" +#include "llvm/ParameterAttributes.h" #include "llvm/TypeSymbolTable.h" #include "llvm/Bytecode/Format.h" #include "llvm/Config/alloca.h" @@ -288,6 +289,8 @@ if (Num < Locals->size()) return Locals->getOperand(Num); + // We did not find the value. + if (!Create) return 0; // Do not create a placeholder? // Did we already create a place holder? @@ -1005,21 +1008,18 @@ } case Type::FunctionTyID: { const Type *RetType = readType(); - unsigned RetAttr = read_vbr_uint(); - unsigned NumParams = read_vbr_uint(); std::vector<const Type*> Params; - std::vector<FunctionType::ParameterAttributes> Attrs; - Attrs.push_back(FunctionType::ParameterAttributes(RetAttr)); while (NumParams--) { Params.push_back(readType()); - if (Params.back() != Type::VoidTy) - Attrs.push_back(FunctionType::ParameterAttributes(read_vbr_uint())); } bool isVarArg = Params.size() && Params.back() == Type::VoidTy; - if (isVarArg) Params.pop_back(); + if (isVarArg) + Params.pop_back(); + + ParamAttrsList *Attrs = ParseParamAttrsList(); Result = FunctionType::get(RetType, Params, isVarArg, Attrs); break; @@ -1076,6 +1076,21 @@ return Result; } +ParamAttrsList *BytecodeReader::ParseParamAttrsList() { + unsigned NumAttrs = read_vbr_uint(); + ParamAttrsList *Attrs = 0; + if (NumAttrs) { + Attrs = new ParamAttrsList(); + while (NumAttrs--) { + uint16_t index = read_vbr_uint(); + uint16_t attrs = read_vbr_uint(); + Attrs->addAttributes(index, attrs); + } + } + return Attrs; +} + + // ParseTypes - We have to use this weird code to handle recursive // types. We know that recursive types will only reference the current slab of // values in the type plane, but they can forward reference types before they @@ -2106,4 +2121,3 @@ //===----------------------------------------------------------------------===// BytecodeHandler::~BytecodeHandler() {} - Index: llvm/lib/Bytecode/Reader/Reader.h diff -u llvm/lib/Bytecode/Reader/Reader.h:1.51 llvm/lib/Bytecode/Reader/Reader.h:1.52 --- llvm/lib/Bytecode/Reader/Reader.h:1.51 Thu Mar 29 13:58:08 2007 +++ llvm/lib/Bytecode/Reader/Reader.h Mon Apr 9 01:14:31 2007 @@ -236,6 +236,7 @@ /// @brief Parse global types void ParseGlobalTypes(); + /// @brief Parse a basic block (for LLVM 1.0 basic block blocks) BasicBlock* ParseBasicBlock(unsigned BlockNo); @@ -264,6 +265,9 @@ /// @brief Parse a single type constant const Type *ParseType(); + /// @brief Parse a list of parameter attributes + ParamAttrsList *ParseParamAttrsList(); + /// @brief Parse a string constants block void ParseStringConstants(unsigned NumEntries, ValueTable &Tab); _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits