summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Bytecode/Reader/Reader.cpp
diff options
context:
space:
mode:
authorReid Spencer <rspencer@reidspencer.com>2007-04-09 06:14:31 +0000
committerReid Spencer <rspencer@reidspencer.com>2007-04-09 06:14:31 +0000
commit52796e819fa3dd61f9513c71a94433ee7ba35a76 (patch)
tree5ff7574c576b36517c873af820b370d726ba1296 /llvm/lib/Bytecode/Reader/Reader.cpp
parente76289b8eacea3a13ba5bfc29c562f16ee947e3e (diff)
downloadbcm5719-llvm-52796e819fa3dd61f9513c71a94433ee7ba35a76.tar.gz
bcm5719-llvm-52796e819fa3dd61f9513c71a94433ee7ba35a76.zip
For 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. llvm-svn: 35811
Diffstat (limited to 'llvm/lib/Bytecode/Reader/Reader.cpp')
-rw-r--r--llvm/lib/Bytecode/Reader/Reader.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/llvm/lib/Bytecode/Reader/Reader.cpp b/llvm/lib/Bytecode/Reader/Reader.cpp
index 82b1888e6aa..ffb731f3141 100644
--- a/llvm/lib/Bytecode/Reader/Reader.cpp
+++ b/llvm/lib/Bytecode/Reader/Reader.cpp
@@ -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 @@ Value * BytecodeReader::getValue(unsigned type, unsigned oNum, bool Create) {
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 @@ const Type *BytecodeReader::ParseType() {
}
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 @@ const Type *BytecodeReader::ParseType() {
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 @@ bool BytecodeReader::ParseBytecode(volatile BufPtr Buf, unsigned Length,
//===----------------------------------------------------------------------===//
BytecodeHandler::~BytecodeHandler() {}
-
OpenPOWER on IntegriCloud