aboutsummaryrefslogtreecommitdiff
path: root/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
commit91ac04aa86129b1017f04bd0a361b293f0562614 (patch)
tree49c0b22892665a2321a18456b0e7ca572ebde6e1 /lib/Bytecode/Reader/Reader.cpp
parent8129a3921e970a546c8108290dcfa10e050e71f0 (diff)
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. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@35811 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Bytecode/Reader/Reader.cpp')
-rw-r--r--lib/Bytecode/Reader/Reader.cpp30
1 files changed, 22 insertions, 8 deletions
diff --git a/lib/Bytecode/Reader/Reader.cpp b/lib/Bytecode/Reader/Reader.cpp
index 82b1888e6a..ffb731f314 100644
--- a/lib/Bytecode/Reader/Reader.cpp
+++ b/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() {}
-