[llvm-commits] [llvm] r50148 - in /llvm/branches/ggreif/use-diet/lib/Bitcode/Reader: BitcodeReader.cpp BitcodeReader.h
Gabor Greif
ggreif at gmail.com
Wed Apr 23 07:42:34 PDT 2008
Author: ggreif
Date: Wed Apr 23 09:42:33 2008
New Revision: 50148
URL: http://llvm.org/viewvc/llvm-project?rev=50148&view=rev
Log:
keep capacity in member variable instead of recalculating it. avoid double overallocation. cleanups.
Modified:
llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp
llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h
Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp?rev=50148&r1=50147&r2=50148&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.cpp Wed Apr 23 09:42:33 2008
@@ -147,19 +147,16 @@
}
void BitcodeReaderValueList::resize(unsigned Desired) {
- unsigned Capacity = 0;
- if (OperandList) {
- Capacity = OperandList->getImpliedUser() - OperandList;
- }
-
if (Desired > Capacity)
{
- Use *New = allocHungoffUses(Desired*2+100);
- for (int i(getNumOperands() - 1); i >= 0; --i)
- New[i] = getOperand(i);
+ Capacity = Desired * 2 + 100;
+ Use *New = allocHungoffUses(Capacity);
Use *Old = OperandList;
+ unsigned Ops = getNumOperands();
+ for (int i(Ops - 1); i >= 0; --i)
+ New[i] = Old[i].get();
OperandList = New;
- if (Old) dropHungoffUses(Old);
+ if (Old) Use::zap(Old, Old + Ops, true);
}
}
@@ -167,8 +164,7 @@
const Type *Ty) {
if (Idx >= size()) {
// Insert a bunch of null values.
- resize(Idx * 2 + 1);
-// OperandList = &Uses[0];
+ resize(Idx + 1);
NumOperands = Idx+1;
}
@@ -186,8 +182,7 @@
Value *BitcodeReaderValueList::getValueFwdRef(unsigned Idx, const Type *Ty) {
if (Idx >= size()) {
// Insert a bunch of null values.
- resize(Idx * 2 + 1);
-// OperandList = &Uses[0];
+ resize(Idx + 1);
NumOperands = Idx+1;
}
Modified: llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h?rev=50148&r1=50147&r2=50148&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h (original)
+++ llvm/branches/ggreif/use-diet/lib/Bitcode/Reader/BitcodeReader.h Wed Apr 23 09:42:33 2008
@@ -31,9 +31,11 @@
//===----------------------------------------------------------------------===//
class BitcodeReaderValueList : public User {
+ unsigned Capacity;
public:
- BitcodeReaderValueList() : User(Type::VoidTy, Value::ArgumentVal, 0, 0) {}
-
+ BitcodeReaderValueList() : User(Type::VoidTy, Value::ArgumentVal, 0, 0)
+ , Capacity(0) {}
+
/// Provide fast operand accessors
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@@ -44,11 +46,12 @@
unsigned OldOps(NumOperands), NewOps(NumOperands + 1);
resize(NewOps);
NumOperands = NewOps;
- OperandList[OldOps].init(V, this);
+ OperandList[OldOps] = V;
}
void clear() {
if (OperandList) dropHungoffUses(OperandList);
+ Capacity = 0;
}
Value *operator[](unsigned i) const { return getOperand(i); }
More information about the llvm-commits
mailing list