#include "llvm/ParamAttrsList.h"
#include "llvm/AutoUpgrade.h"
#include "llvm/ADT/SmallString.h"
+#include "llvm/ADT/SmallVector.h"
#include "llvm/Support/MathExtras.h"
#include "llvm/Support/MemoryBuffer.h"
using namespace llvm;
Buffer = 0;
std::vector<PATypeHolder>().swap(TypeList);
ValueList.clear();
+
+ // Drop references to ParamAttrs.
+ for (unsigned i = 0, e = ParamAttrs.size(); i != e; ++i)
+ ParamAttrs[i]->dropRef();
+
std::vector<const ParamAttrsList*>().swap(ParamAttrs);
std::vector<BasicBlock*>().swap(FunctionBBs);
std::vector<Function*>().swap(FunctionsWithBodies);
if (Record[i+1] != ParamAttr::None)
Attrs.push_back(ParamAttrsWithIndex::get(Record[i], Record[i+1]));
}
- ParamAttrs.push_back(Attrs.empty() ? NULL : ParamAttrsList::get(Attrs));
+ if (Attrs.empty()) {
+ ParamAttrs.push_back(0);
+ } else {
+ ParamAttrs.push_back(ParamAttrsList::get(Attrs));
+ ParamAttrs.back()->addRef();
+ }
+
Attrs.clear();
break;
}
break;
}
// ALIAS: [alias type, aliasee val#, linkage]
+ // ALIAS: [alias type, aliasee val#, linkage, visibility]
case bitc::MODULE_CODE_ALIAS: {
if (Record.size() < 3)
return Error("Invalid MODULE_ALIAS record");
GlobalAlias *NewGA = new GlobalAlias(Ty, GetDecodedLinkage(Record[2]),
"", 0, TheModule);
+ // Old bitcode files didn't have visibility field.
+ if (Record.size() > 3)
+ NewGA->setVisibility(GetDecodedVisibility(Record[3]));
ValueList.push_back(NewGA);
AliasInits.push_back(std::make_pair(NewGA, Record[1]));
break;
CurBB = FunctionBBs[0];
continue;
+ case bitc::FUNC_CODE_INST_BB_UNWINDDEST: // BB_UNWINDDEST: [bb#]
+ if (CurBB->getUnwindDest())
+ return Error("Only permit one BB_UNWINDDEST per BB");
+ if (Record.size() != 1)
+ return Error("Invalid BB_UNWINDDEST record");
+
+ CurBB->setUnwindDest(getBasicBlock(Record[0]));
+ continue;
+
case bitc::FUNC_CODE_INST_BINOP: { // BINOP: [opval, ty, opval, opcode]
unsigned OpNum = 0;
Value *LHS, *RHS;
}
case bitc::FUNC_CODE_INST_RET: // RET: [opty,opval<optional>]
- if (Record.empty()) {
- I = new ReturnInst();
- break;
- } else {
- unsigned OpNum = 0;
- Value *Op;
- if (getValueTypePair(Record, OpNum, NextValueNo, Op) ||
- OpNum != Record.size())
- return Error("Invalid RET record");
- I = new ReturnInst(Op);
- break;
+ {
+ unsigned Size = Record.size();
+ if (Size == 0) {
+ I = new ReturnInst();
+ break;
+ } else {
+ unsigned OpNum = 0;
+ SmallVector<Value *,4> Vs;
+ do {
+ Value *Op = NULL;
+ if (getValueTypePair(Record, OpNum, NextValueNo, Op))
+ return Error("Invalid RET record");
+ Vs.push_back(Op);
+ } while(OpNum != Record.size());
+
+ // SmallVector Vs has at least one element.
+ I = new ReturnInst(&Vs[0], Vs.size());
+ break;
+ }
}
case bitc::FUNC_CODE_INST_BR: { // BR: [bb#, bb#, opval] or [bb#]
if (Record.size() != 1 && Record.size() != 3)