[llvm-commits] [llvm] r49425 - in /llvm/branches/ggreif/use-diet: include/llvm/BasicBlock.h include/llvm/GlobalAlias.h include/llvm/GlobalVariable.h include/llvm/InstrTypes.h include/llvm/Instructions.h include/llvm/Use.h include/llvm/User.h lib/VMCore/BasicBlock.cpp lib/VMCore/Constants.cpp lib/VMCore/Globals.cpp lib/VMCore/Instructions.cpp lib/VMCore/Use.cpp
Gabor Greif
ggreif at gmail.com
Wed Apr 9 07:39:56 PDT 2008
Author: ggreif
Date: Wed Apr 9 09:39:56 2008
New Revision: 49425
URL: http://llvm.org/viewvc/llvm-project?rev=49425&view=rev
Log:
major surgery to get rid of embedded Uses. BitcodeReader does not compile yet.
Modified:
llvm/branches/ggreif/use-diet/include/llvm/BasicBlock.h
llvm/branches/ggreif/use-diet/include/llvm/GlobalAlias.h
llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h
llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h
llvm/branches/ggreif/use-diet/include/llvm/Instructions.h
llvm/branches/ggreif/use-diet/include/llvm/Use.h
llvm/branches/ggreif/use-diet/include/llvm/User.h
llvm/branches/ggreif/use-diet/lib/VMCore/BasicBlock.cpp
llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp
llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp
llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp
llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp
Modified: llvm/branches/ggreif/use-diet/include/llvm/BasicBlock.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/BasicBlock.h?rev=49425&r1=49424&r2=49425&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/BasicBlock.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/BasicBlock.h Wed Apr 9 09:39:56 2008
@@ -52,11 +52,11 @@
class BasicBlock : public User { // Basic blocks are data objects also
public:
typedef iplist<Instruction> InstListType;
-private :
+private:
InstListType InstList;
BasicBlock *Prev, *Next; // Next and Prev links for our intrusive linked list
Function *Parent;
- Use unwindDest;
+/* Use unwindDest;*/
void setParent(Function *parent);
void setNext(BasicBlock *N) { Next = N; }
Modified: llvm/branches/ggreif/use-diet/include/llvm/GlobalAlias.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/GlobalAlias.h?rev=49425&r1=49424&r2=49425&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/GlobalAlias.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/GlobalAlias.h Wed Apr 9 09:39:56 2008
@@ -42,11 +42,10 @@
GlobalAlias *getPrev() { return Prev; }
const GlobalAlias *getPrev() const { return Prev; }
- Use Aliasee;
public:
- // allocate space for exactly zero operands
+ // allocate space for exactly one operand
void *operator new(size_t s) {
- return User::operator new(s, 0);
+ return User::operator new(s, 1);
}
/// GlobalAlias ctor - If a parent module is specified, the alias is
/// automatically inserted into the end of the specified module's alias list.
Modified: llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h?rev=49425&r1=49424&r2=49425&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/GlobalVariable.h Wed Apr 9 09:39:56 2008
@@ -44,12 +44,11 @@
bool isConstantGlobal : 1; // Is this a global constant?
bool isThreadLocalSymbol : 1; // Is this symbol "Thread Local"?
- Use Initializer;
public:
- // allocate space for exactly zero operands
+ // allocate space for exactly one operand
void *operator new(size_t s) {
- return User::operator new(s, 0);
+ return User::operator new(s, 1); // FIXME: if no initializer, then 0
}
/// GlobalVariable ctor - If a parent module is specified, the global is
/// automatically inserted into the end of the specified modules global list.
@@ -81,22 +80,22 @@
///
inline Constant *getInitializer() const {
assert(hasInitializer() && "GV doesn't have initializer!");
- return reinterpret_cast<Constant*>(Initializer.get());
+ return static_cast<Constant*>(Op<0>().get());
}
inline Constant *getInitializer() {
assert(hasInitializer() && "GV doesn't have initializer!");
- return reinterpret_cast<Constant*>(Initializer.get());
+ return static_cast<Constant*>(Op<0>().get());
}
inline void setInitializer(Constant *CPV) {
if (CPV == 0) {
if (hasInitializer()) {
- Initializer.set(0);
+ Op<0>().set(0);
NumOperands = 0;
}
} else {
if (!hasInitializer())
NumOperands = 1;
- Initializer.set(CPV);
+ Op<0>().set(CPV);
}
}
Modified: llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h?rev=49425&r1=49424&r2=49425&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/InstrTypes.h Wed Apr 9 09:39:56 2008
@@ -84,16 +84,15 @@
class UnaryInstruction : public Instruction {
void *operator new(size_t, unsigned); // Do not implement
- Use Op;
- // avoiding warning: 'this' : used in base member initializer list
- UnaryInstruction* this_() { return this; }
protected:
- UnaryInstruction(const Type *Ty, unsigned iType, Value *V, Instruction *IB =0)
- : Instruction(Ty, iType, &Op, 1, IB), Op(V, this_()) {
+ UnaryInstruction(const Type *Ty, unsigned iType, Value *V, Instruction *IB = 0)
+ : Instruction(Ty, iType, &Op<0>(), 1, IB) {
+ Op<0>() = V;
}
UnaryInstruction(const Type *Ty, unsigned iType, Value *V, BasicBlock *IAE)
- : Instruction(Ty, iType, &Op, 1, IAE), Op(V, this_()) {
+ : Instruction(Ty, iType, &Op<0>(), 1, IAE) {
+ Op<0>() = V;
}
public:
// allocate space for exactly one operand
@@ -107,11 +106,11 @@
// Transparently provide more efficient getOperand methods.
Value *getOperand(unsigned i) const {
assert(i == 0 && "getOperand() out of range!");
- return Op;
+ return Op<0>();
}
void setOperand(unsigned i, Value *Val) {
assert(i == 0 && "setOperand() out of range!");
- Op = Val;
+ Op<0>() = Val;
}
unsigned getNumOperands() const { return 1; }
@@ -136,7 +135,6 @@
class BinaryOperator : public Instruction {
void *operator new(size_t, unsigned); // Do not implement
- Use Ops[2];
protected:
void init(BinaryOps iType);
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
@@ -152,11 +150,11 @@
/// Transparently provide more efficient getOperand methods.
Value *getOperand(unsigned i) const {
assert(i < 2 && "getOperand() out of range!");
- return Ops[i];
+ return OperandList[i];
}
void setOperand(unsigned i, Value *Val) {
assert(i < 2 && "setOperand() out of range!");
- Ops[i] = Val;
+ OperandList[i] = Val;
}
unsigned getNumOperands() const { return 2; }
@@ -509,8 +507,6 @@
CmpInst(Instruction::OtherOps op, unsigned short pred, Value *LHS, Value *RHS,
const std::string &Name, BasicBlock *InsertAtEnd);
- Use Ops[2]; // CmpInst instructions always have 2 operands, optimize
-
public:
// allocate space for exactly two operands
void *operator new(size_t s) {
@@ -552,11 +548,11 @@
/// @brief Provide more efficient getOperand methods.
Value *getOperand(unsigned i) const {
assert(i < 2 && "getOperand() out of range!");
- return Ops[i];
+ return OperandList[i];
}
void setOperand(unsigned i, Value *Val) {
assert(i < 2 && "setOperand() out of range!");
- Ops[i] = Val;
+ OperandList[i] = Val;
}
/// @brief CmpInst instructions always have 2 operands.
Modified: llvm/branches/ggreif/use-diet/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Instructions.h?rev=49425&r1=49424&r2=49425&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Wed Apr 9 09:39:56 2008
@@ -288,11 +288,10 @@
///
class StoreInst : public Instruction {
void *operator new(size_t, unsigned); // DO NOT IMPLEMENT
- Use Ops[2];
- StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store, Ops, 2) {
- Ops[0].init(SI.Ops[0], this);
- Ops[1].init(SI.Ops[1], this);
+ StoreInst(const StoreInst &SI) : Instruction(SI.getType(), Store, &Op<0>(), 2) {
+ Op<0>().init(SI.Op<0>(), this);
+ Op<1>().init(SI.Op<1>(), this);
setVolatile(SI.isVolatile());
setAlignment(SI.getAlignment());
@@ -331,11 +330,11 @@
/// Transparently provide more efficient getOperand methods.
Value *getOperand(unsigned i) const {
assert(i < 2 && "getOperand() out of range!");
- return Ops[i];
+ return OperandList[i];
}
void setOperand(unsigned i, Value *Val) {
assert(i < 2 && "setOperand() out of range!");
- Ops[i] = Val;
+ OperandList[i] = Val;
}
unsigned getNumOperands() const { return 2; }
@@ -383,7 +382,7 @@
GetElementPtrInst(const GetElementPtrInst &GEPI)
: Instruction(reinterpret_cast<const Type*>(GEPI.getType()), GetElementPtr,
0, GEPI.getNumOperands()) {
- Use *OL = OperandList = new Use[NumOperands];
+ Use *OL = OperandList = 0; // FIXME: GEPI.dupHangoffUses(this, NumOperands, GEPI.OperandList) new Use[NumOperands];
Use *GEPIOL = GEPI.OperandList;
for (unsigned i = 0, E = NumOperands; i != E; ++i)
OL[i].init(GEPIOL[i], this);
@@ -401,7 +400,7 @@
std::distance(IdxBegin, IdxEnd);
if (NumIdx > 0) {
- // This requires that the itoerator points to contiguous memory.
+ // This requires that the iterator points to contiguous memory.
init(Ptr, &*IdxBegin, NumIdx);
}
else {
@@ -725,7 +724,7 @@
/// @brief Swap operands and adjust predicate.
void swapOperands() {
SubclassData = getSwappedPredicate();
- std::swap(Ops[0], Ops[1]);
+ std::swap(Op<0>(), Op<1>());
}
virtual ICmpInst *clone() const;
@@ -849,7 +848,7 @@
/// @brief Swap operands and adjust predicate.
void swapOperands() {
SubclassData = getSwappedPredicate();
- std::swap(Ops[0], Ops[1]);
+ std::swap(Op<0>(), Op<1>());
}
virtual FCmpInst *clone() const;
@@ -1053,27 +1052,25 @@
/// SelectInst - This class represents the LLVM 'select' instruction.
///
class SelectInst : public Instruction {
- Use Ops[3];
-
void init(Value *C, Value *S1, Value *S2) {
- Ops[0].init(C, this);
- Ops[1].init(S1, this);
- Ops[2].init(S2, this);
+ Op<0>() = C;
+ Op<1>() = S1;
+ Op<2>() = S2;
}
SelectInst(const SelectInst &SI)
- : Instruction(SI.getType(), SI.getOpcode(), Ops, 3) {
- init(SI.Ops[0], SI.Ops[1], SI.Ops[2]);
+ : Instruction(SI.getType(), SI.getOpcode(), &Op<0>(), 3) {
+ init(SI.Op<0>(), SI.Op<1>(), SI.Op<2>());
}
SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name = "",
Instruction *InsertBefore = 0)
- : Instruction(S1->getType(), Instruction::Select, Ops, 3, InsertBefore) {
+ : Instruction(S1->getType(), Instruction::Select, &Op<0>(), 3, InsertBefore) {
init(C, S1, S2);
setName(Name);
}
SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name,
BasicBlock *InsertAtEnd)
- : Instruction(S1->getType(), Instruction::Select, Ops, 3, InsertAtEnd) {
+ : Instruction(S1->getType(), Instruction::Select, &Op<0>(), 3, InsertAtEnd) {
init(C, S1, S2);
setName(Name);
}
@@ -1087,18 +1084,18 @@
return new(3) SelectInst(C, S1, S2, Name, InsertAtEnd);
}
- Value *getCondition() const { return Ops[0]; }
- Value *getTrueValue() const { return Ops[1]; }
- Value *getFalseValue() const { return Ops[2]; }
+ Value *getCondition() const { return Op<0>(); }
+ Value *getTrueValue() const { return Op<1>(); }
+ Value *getFalseValue() const { return Op<2>(); }
/// Transparently provide more efficient getOperand methods.
Value *getOperand(unsigned i) const {
assert(i < 3 && "getOperand() out of range!");
- return Ops[i];
+ return OperandList[i];
}
void setOperand(unsigned i, Value *Val) {
assert(i < 3 && "setOperand() out of range!");
- Ops[i] = Val;
+ OperandList[i] = Val;
}
unsigned getNumOperands() const { return 3; }
@@ -1160,11 +1157,10 @@
/// element from a VectorType value
///
class ExtractElementInst : public Instruction {
- Use Ops[2];
ExtractElementInst(const ExtractElementInst &EE) :
- Instruction(EE.getType(), ExtractElement, Ops, 2) {
- Ops[0].init(EE.Ops[0], this);
- Ops[1].init(EE.Ops[1], this);
+ Instruction(EE.getType(), ExtractElement, &Op<0>(), 2) {
+ Op<0>().init(EE.Op<0>(), this);
+ Op<1>().init(EE.Op<1>(), this);
}
public:
@@ -1190,11 +1186,11 @@
/// Transparently provide more efficient getOperand methods.
Value *getOperand(unsigned i) const {
assert(i < 2 && "getOperand() out of range!");
- return Ops[i];
+ return OperandList[i];
}
void setOperand(unsigned i, Value *Val) {
assert(i < 2 && "setOperand() out of range!");
- Ops[i] = Val;
+ OperandList[i] = Val;
}
unsigned getNumOperands() const { return 2; }
@@ -1216,7 +1212,6 @@
/// element into a VectorType value
///
class InsertElementInst : public Instruction {
- Use Ops[3];
InsertElementInst(const InsertElementInst &IE);
InsertElementInst(Value *Vec, Value *NewElt, Value *Idx,
const std::string &Name = "",Instruction *InsertBefore = 0);
@@ -1263,11 +1258,11 @@
/// Transparently provide more efficient getOperand methods.
Value *getOperand(unsigned i) const {
assert(i < 3 && "getOperand() out of range!");
- return Ops[i];
+ return OperandList[i];
}
void setOperand(unsigned i, Value *Val) {
assert(i < 3 && "setOperand() out of range!");
- Ops[i] = Val;
+ OperandList[i] = Val;
}
unsigned getNumOperands() const { return 3; }
@@ -1289,7 +1284,6 @@
/// input vectors.
///
class ShuffleVectorInst : public Instruction {
- Use Ops[3];
ShuffleVectorInst(const ShuffleVectorInst &IE);
public:
// allocate space for exactly three operands
@@ -1317,15 +1311,15 @@
/// Transparently provide more efficient getOperand methods.
const Value *getOperand(unsigned i) const {
assert(i < 3 && "getOperand() out of range!");
- return Ops[i];
+ return OperandList[i];
}
Value *getOperand(unsigned i) {
assert(i < 3 && "getOperand() out of range!");
- return Ops[i];
+ return OperandList[i];
}
void setOperand(unsigned i, Value *Val) {
assert(i < 3 && "setOperand() out of range!");
- Ops[i] = Val;
+ OperandList[i] = Val;
}
unsigned getNumOperands() const { return 3; }
@@ -1497,7 +1491,6 @@
/// does not continue in this function any longer.
///
class ReturnInst : public TerminatorInst {
- Use RetVal;
ReturnInst(const ReturnInst &RI);
void init(Value * const* retVals, unsigned N);
@@ -1549,7 +1542,7 @@
if (getNumOperands() > 1)
return TerminatorInst::getOperand(n);
else
- return RetVal;
+ return Op<0>();
}
Value *getReturnValue(unsigned n = 0) const {
@@ -1583,7 +1576,6 @@
/// Ops list - Branches are strange. The operands are ordered:
/// TrueDest, FalseDest, Cond. This makes some accessors faster because
/// they don't have to check for cond/uncond branchness.
- Use Ops[3];
BranchInst(const BranchInst &BI);
void AssertOK();
// BranchInst constructors (where {B, T, F} are blocks, and C is a condition):
@@ -1618,11 +1610,11 @@
/// Transparently provide more efficient getOperand methods.
Value *getOperand(unsigned i) const {
assert(i < getNumOperands() && "getOperand() out of range!");
- return Ops[i];
+ return OperandList[i];
}
void setOperand(unsigned i, Value *Val) {
assert(i < getNumOperands() && "setOperand() out of range!");
- Ops[i] = Val;
+ OperandList[i] = Val;
}
virtual BranchInst *clone() const;
@@ -1646,8 +1638,8 @@
void setUnconditionalDest(BasicBlock *Dest) {
if (isConditional()) { // Convert this to an uncond branch.
NumOperands = 1;
- Ops[1].set(0);
- Ops[2].set(0);
+ Op<1>().set(0);
+ Op<2>().set(0);
}
setOperand(0, reinterpret_cast<Value*>(Dest));
}
@@ -2552,11 +2544,10 @@
///
class GetResultInst : public /*FIXME: Unary*/Instruction {
void *operator new(size_t, unsigned); // DO NOT IMPLEMENT
- Use Aggr;
unsigned Idx;
GetResultInst(const GetResultInst &GRI) :
- Instruction(GRI.getType(), Instruction::GetResult, &Aggr, 1) {
- Aggr.init(GRI.Aggr, this);
+ Instruction(GRI.getType(), Instruction::GetResult, &Op<0>(), 1) {
+ Op<0>().init(GRI.Op<0>(), this);
Idx = GRI.Idx;
}
Modified: llvm/branches/ggreif/use-diet/include/llvm/Use.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/Use.h?rev=49425&r1=49424&r2=49425&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/Use.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/Use.h Wed Apr 9 09:39:56 2008
@@ -35,15 +35,19 @@
public:
inline void init(Value *V, User *U);
- Use(Value *V, User *U) { init(V, U); }
+/* Use(Value *V, User *U) { init(V, U); }
Use(const Use &U) { init(U.get(), U.U); }
+*/
inline ~Use() {
if (get()) removeFromList();
}
/// Default ctor - This leaves the Use completely uninitialized. The only thing
/// that is valid to do with this use is to call the "init" method.
+
+private:
inline Use() {}
+public:
operator Value*() const { return stripTag(Val); }
@@ -68,9 +72,9 @@
Use *getNext() const { return Next; }
private:
+ User *U;
Use *Next, **Prev;
Value *Val;
- User *U;
static Value *stripTag(Value *V) {
return reinterpret_cast<Value*>(reinterpret_cast<ptrdiff_t>(V) & ~3UL);
Modified: llvm/branches/ggreif/use-diet/include/llvm/User.h
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/include/llvm/User.h?rev=49425&r1=49424&r2=49425&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/User.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/User.h Wed Apr 9 09:39:56 2008
@@ -208,11 +208,14 @@
void *Storage = ::operator new(s + sizeof(Use) * Us);
Use *Start = static_cast<Use*>(Storage);
Use *End = Start + Us;
+ User *Obj = reinterpret_cast<User*>(End);
+ Obj->OperandList = Start;
+ Obj->NumOperands = Us;
Use::initTags(Start, End);
- return End;
+ return Obj;
}
User(const Type *Ty, unsigned vty, Use *OpList, unsigned NumOps)
- : Value(Ty, vty), OperandList(OpList), NumOperands(NumOps) {}
+ : Value(Ty, vty)/*, OperandList(OpList), NumOperands(NumOps)*/ {}
public:
void operator delete(void *Usr) {
User *Start = static_cast<User*>(Usr);
@@ -222,6 +225,10 @@
else ::operator delete(Usr);
}
public:
+ template <unsigned> Use &Op();
+ template <unsigned> const Use &Op() const;
+ Use *allocHangoffUses(unsigned) const;
+
Value *getOperand(unsigned i) const {
assert(i < NumOperands && "getOperand() out of range!");
return OperandList[i];
Modified: llvm/branches/ggreif/use-diet/lib/VMCore/BasicBlock.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/BasicBlock.cpp?rev=49425&r1=49424&r2=49425&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/BasicBlock.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/BasicBlock.cpp Wed Apr 9 09:39:56 2008
@@ -75,7 +75,7 @@
BasicBlock::BasicBlock(const std::string &Name, Function *NewParent,
BasicBlock *InsertBefore, BasicBlock *Dest)
- : User(Type::LabelTy, Value::BasicBlockVal, &unwindDest, 0/*FIXME*/), Parent(0) {
+ : User(Type::LabelTy, Value::BasicBlockVal, &Op<0>()/*unwindDest*/, 0/*FIXME*/), Parent(0) {
// Make sure that we get added to a function
LeakDetector::addGarbageObject(this);
@@ -89,8 +89,9 @@
}
setName(Name);
- unwindDest.init(NULL, this);
- setUnwindDest(Dest);
+ // Op<0>()./*unwindDest.*/init(NULL, this); /*FIXME*/
+ if (Dest)
+ setUnwindDest(Dest);
}
@@ -120,16 +121,17 @@
}
const BasicBlock *BasicBlock::getUnwindDest() const {
- return cast_or_null<const BasicBlock>(unwindDest.get());
+ return cast_or_null<const BasicBlock>(Op<0>().get());
}
BasicBlock *BasicBlock::getUnwindDest() {
- return cast_or_null<BasicBlock>(unwindDest.get());
+ return cast_or_null<BasicBlock>(Op<0>().get());
}
void BasicBlock::setUnwindDest(BasicBlock *dest) {
- NumOperands = unwindDest ? 1 : 0;
- unwindDest.set(dest);
+// NumOperands = unwindDest ? 1 : 0;
+ if (dest) // FIXME
+ Op<0>().set(dest);
}
/// moveBefore - Unlink this basic block from its current function and
Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp?rev=49425&r1=49424&r2=49425&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Constants.cpp Wed Apr 9 09:39:56 2008
@@ -341,7 +341,7 @@
ConstantArray::ConstantArray(const ArrayType *T,
const std::vector<Constant*> &V)
- : Constant(T, ConstantArrayVal, new Use[V.size()], V.size()) {
+ : Constant(T, ConstantArrayVal, allocHangoffUses(V.size()), V.size()) {
assert(V.size() == T->getNumElements() &&
"Invalid initializer vector for constant array");
Use *OL = OperandList;
@@ -357,12 +357,12 @@
}
ConstantArray::~ConstantArray() {
- delete [] OperandList;
+// delete [] OperandList;
}
ConstantStruct::ConstantStruct(const StructType *T,
const std::vector<Constant*> &V)
- : Constant(T, ConstantStructVal, new Use[V.size()], V.size()) {
+ : Constant(T, ConstantStructVal, allocHangoffUses(V.size()), V.size()) {
assert(V.size() == T->getNumElements() &&
"Invalid initializer vector for constant structure");
Use *OL = OperandList;
@@ -386,7 +386,7 @@
ConstantVector::ConstantVector(const VectorType *T,
const std::vector<Constant*> &V)
- : Constant(T, ConstantVectorVal, new Use[V.size()], V.size()) {
+ : Constant(T, ConstantVectorVal, allocHangoffUses(V.size()), V.size()) {
Use *OL = OperandList;
for (std::vector<Constant*>::const_iterator I = V.begin(), E = V.end();
I != E; ++I, ++OL) {
@@ -400,7 +400,7 @@
}
ConstantVector::~ConstantVector() {
- delete [] OperandList;
+// delete [] OperandList;
}
// We declare several classes private to this file, so use an anonymous
@@ -411,30 +411,30 @@
/// behind the scenes to implement unary constant exprs.
class VISIBILITY_HIDDEN UnaryConstantExpr : public ConstantExpr {
void *operator new(size_t, unsigned); // DO NOT IMPLEMENT
- Use Op;
public:
// allocate space for exactly one operand
void *operator new(size_t s) {
return User::operator new(s, 1);
}
UnaryConstantExpr(unsigned Opcode, Constant *C, const Type *Ty)
- : ConstantExpr(Ty, Opcode, &Op, 1), Op(C, this) {}
+ : ConstantExpr(Ty, Opcode, &Op<0>(), 1) {
+ Op<0>() = C;
+ }
};
/// BinaryConstantExpr - This class is private to Constants.cpp, and is used
/// behind the scenes to implement binary constant exprs.
class VISIBILITY_HIDDEN BinaryConstantExpr : public ConstantExpr {
void *operator new(size_t, unsigned); // DO NOT IMPLEMENT
- Use Ops[2];
public:
// allocate space for exactly two operands
void *operator new(size_t s) {
return User::operator new(s, 2);
}
BinaryConstantExpr(unsigned Opcode, Constant *C1, Constant *C2)
- : ConstantExpr(C1->getType(), Opcode, Ops, 2) {
- Ops[0].init(C1, this);
- Ops[1].init(C2, this);
+ : ConstantExpr(C1->getType(), Opcode, &Op<0>(), 2) {
+ Op<0>().init(C1, this);
+ Op<1>().init(C2, this);
}
};
@@ -442,17 +442,16 @@
/// behind the scenes to implement select constant exprs.
class VISIBILITY_HIDDEN SelectConstantExpr : public ConstantExpr {
void *operator new(size_t, unsigned); // DO NOT IMPLEMENT
- Use Ops[3];
public:
// allocate space for exactly three operands
void *operator new(size_t s) {
return User::operator new(s, 3);
}
SelectConstantExpr(Constant *C1, Constant *C2, Constant *C3)
- : ConstantExpr(C2->getType(), Instruction::Select, Ops, 3) {
- Ops[0].init(C1, this);
- Ops[1].init(C2, this);
- Ops[2].init(C3, this);
+ : ConstantExpr(C2->getType(), Instruction::Select, &Op<0>(), 3) {
+ Op<0>().init(C1, this);
+ Op<1>().init(C2, this);
+ Op<2>().init(C3, this);
}
};
@@ -461,7 +460,6 @@
/// extractelement constant exprs.
class VISIBILITY_HIDDEN ExtractElementConstantExpr : public ConstantExpr {
void *operator new(size_t, unsigned); // DO NOT IMPLEMENT
- Use Ops[2];
public:
// allocate space for exactly two operands
void *operator new(size_t s) {
@@ -469,9 +467,9 @@
}
ExtractElementConstantExpr(Constant *C1, Constant *C2)
: ConstantExpr(cast<VectorType>(C1->getType())->getElementType(),
- Instruction::ExtractElement, Ops, 2) {
- Ops[0].init(C1, this);
- Ops[1].init(C2, this);
+ Instruction::ExtractElement, &Op<0>(), 2) {
+ Op<0>().init(C1, this);
+ Op<1>().init(C2, this);
}
};
@@ -480,7 +478,6 @@
/// insertelement constant exprs.
class VISIBILITY_HIDDEN InsertElementConstantExpr : public ConstantExpr {
void *operator new(size_t, unsigned); // DO NOT IMPLEMENT
- Use Ops[3];
public:
// allocate space for exactly three operands
void *operator new(size_t s) {
@@ -488,10 +485,10 @@
}
InsertElementConstantExpr(Constant *C1, Constant *C2, Constant *C3)
: ConstantExpr(C1->getType(), Instruction::InsertElement,
- Ops, 3) {
- Ops[0].init(C1, this);
- Ops[1].init(C2, this);
- Ops[2].init(C3, this);
+ &Op<0>(), 3) {
+ Op<0>().init(C1, this);
+ Op<1>().init(C2, this);
+ Op<2>().init(C3, this);
}
};
@@ -500,7 +497,6 @@
/// shufflevector constant exprs.
class VISIBILITY_HIDDEN ShuffleVectorConstantExpr : public ConstantExpr {
void *operator new(size_t, unsigned); // DO NOT IMPLEMENT
- Use Ops[3];
public:
// allocate space for exactly three operands
void *operator new(size_t s) {
@@ -508,10 +504,10 @@
}
ShuffleVectorConstantExpr(Constant *C1, Constant *C2, Constant *C3)
: ConstantExpr(C1->getType(), Instruction::ShuffleVector,
- Ops, 3) {
- Ops[0].init(C1, this);
- Ops[1].init(C2, this);
- Ops[2].init(C3, this);
+ &Op<0>(), 3) {
+ Op<0>().init(C1, this);
+ Op<1>().init(C2, this);
+ Op<2>().init(C3, this);
}
};
@@ -521,7 +517,7 @@
GetElementPtrConstantExpr(Constant *C, const std::vector<Constant*> &IdxList,
const Type *DestTy)
: ConstantExpr(DestTy, Instruction::GetElementPtr,
- new Use[IdxList.size()+1], IdxList.size()+1) {
+ allocHangoffUses(IdxList.size()+1), IdxList.size()+1) {
OperandList[0].init(C, this);
for (unsigned i = 0, E = IdxList.size(); i != E; ++i)
OperandList[i+1].init(IdxList[i], this);
@@ -546,10 +542,9 @@
return User::operator new(s, 2);
}
unsigned short predicate;
- Use Ops[2];
CompareConstantExpr(Instruction::OtherOps opc, unsigned short pred,
Constant* LHS, Constant* RHS)
- : ConstantExpr(Type::Int1Ty, opc, Ops, 2), predicate(pred) {
+ : ConstantExpr(Type::Int1Ty, opc, &Op<0>(), 2), predicate(pred) {
OperandList[0].init(LHS, this);
OperandList[1].init(RHS, this);
}
Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp?rev=49425&r1=49424&r2=49425&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Globals.cpp Wed Apr 9 09:39:56 2008
@@ -89,14 +89,14 @@
Module *ParentModule, bool ThreadLocal,
unsigned AddressSpace)
: GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalVariableVal,
- &Initializer, InitVal != 0, Link, Name),
+ &Op<0>(), InitVal != 0, Link, Name),
isConstantGlobal(constant), isThreadLocalSymbol(ThreadLocal) {
if (InitVal) {
assert(InitVal->getType() == Ty &&
"Initializer should be the same type as the GlobalVariable!");
- Initializer.init(InitVal, this);
+ Op<0>().init(InitVal, this);
} else {
- Initializer.init(0, this);
+ Op<0>().init(0, this); // FIXME: if no InitVal, then none!
}
LeakDetector::addGarbageObject(this);
@@ -110,14 +110,14 @@
GlobalVariable *Before, bool ThreadLocal,
unsigned AddressSpace)
: GlobalValue(PointerType::get(Ty, AddressSpace), Value::GlobalVariableVal,
- &Initializer, InitVal != 0, Link, Name),
+ &Op<0>(), InitVal != 0, Link, Name),
isConstantGlobal(constant), isThreadLocalSymbol(ThreadLocal) {
if (InitVal) {
assert(InitVal->getType() == Ty &&
"Initializer should be the same type as the GlobalVariable!");
- Initializer.init(InitVal, this);
+ Op<0>().init(InitVal, this);
} else {
- Initializer.init(0, this);
+ Op<0>().init(0, this); // FIXME: if no InitVal, then none!
}
LeakDetector::addGarbageObject(this);
@@ -169,12 +169,12 @@
GlobalAlias::GlobalAlias(const Type *Ty, LinkageTypes Link,
const std::string &Name, Constant* aliasee,
Module *ParentModule)
- : GlobalValue(Ty, Value::GlobalAliasVal, &Aliasee, 1, Link, Name) {
+ : GlobalValue(Ty, Value::GlobalAliasVal, &Op<0>(), 1, Link, Name) {
LeakDetector::addGarbageObject(this);
if (aliasee)
assert(aliasee->getType() == Ty && "Alias and aliasee types should match!");
- Aliasee.init(aliasee, this);
+ Op<0>().init(aliasee, this);
if (ParentModule)
ParentModule->getAliasList().push_back(this);
Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp?rev=49425&r1=49424&r2=49425&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Wed Apr 9 09:39:56 2008
@@ -111,7 +111,7 @@
PHINode::PHINode(const PHINode &PN)
: Instruction(PN.getType(), Instruction::PHI,
- new Use[PN.getNumOperands()], PN.getNumOperands()),
+ allocHangoffUses(PN.getNumOperands()), PN.getNumOperands()),
ReservedSpace(PN.getNumOperands()) {
Use *OL = OperandList;
for (unsigned i = 0, e = PN.getNumOperands(); i != e; i+=2) {
@@ -121,7 +121,7 @@
}
PHINode::~PHINode() {
- delete [] OperandList;
+// delete [] OperandList;
}
// removeIncomingValue - Remove an incoming value. This is useful if a
@@ -177,13 +177,13 @@
}
ReservedSpace = NumOps;
- Use *NewOps = new Use[NumOps];
Use *OldOps = OperandList;
+ Use *NewOps = allocHangoffUses(NumOps);
for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
NewOps[i].init(OldOps[i], this);
OldOps[i].set(0);
}
- delete [] OldOps;
+// delete [] OldOps;
OperandList = NewOps;
}
@@ -241,12 +241,12 @@
//===----------------------------------------------------------------------===//
CallInst::~CallInst() {
- delete [] OperandList;
+// delete [] OperandList;
}
void CallInst::init(Value *Func, Value* const *Params, unsigned NumParams) {
NumOperands = NumParams+1;
- Use *OL = OperandList = new Use[NumParams+1];
+ Use *OL = OperandList = allocHangoffUses(NumParams+1);
OL[0].init(Func, this);
const FunctionType *FTy =
@@ -266,7 +266,7 @@
void CallInst::init(Value *Func, Value *Actual1, Value *Actual2) {
NumOperands = 3;
- Use *OL = OperandList = new Use[3];
+ Use *OL = OperandList = allocHangoffUses(3);
OL[0].init(Func, this);
OL[1].init(Actual1, this);
OL[2].init(Actual2, this);
@@ -288,7 +288,7 @@
void CallInst::init(Value *Func, Value *Actual) {
NumOperands = 2;
- Use *OL = OperandList = new Use[2];
+ Use *OL = OperandList = allocHangoffUses(2);
OL[0].init(Func, this);
OL[1].init(Actual, this);
@@ -306,7 +306,7 @@
void CallInst::init(Value *Func) {
NumOperands = 1;
- Use *OL = OperandList = new Use[1];
+ Use *OL = OperandList = allocHangoffUses(1);
OL[0].init(Func, this);
const FunctionType *FTy =
@@ -352,7 +352,7 @@
}
CallInst::CallInst(const CallInst &CI)
- : Instruction(CI.getType(), Instruction::Call, new Use[CI.getNumOperands()],
+ : Instruction(CI.getType(), Instruction::Call, allocHangoffUses(CI.getNumOperands()),
CI.getNumOperands()) {
setParamAttrs(CI.getParamAttrs());
SubclassData = CI.SubclassData;
@@ -385,13 +385,13 @@
//===----------------------------------------------------------------------===//
InvokeInst::~InvokeInst() {
- delete [] OperandList;
+// delete [] OperandList;
}
void InvokeInst::init(Value *Fn, BasicBlock *IfNormal, BasicBlock *IfException,
Value* const *Args, unsigned NumArgs) {
NumOperands = 3+NumArgs;
- Use *OL = OperandList = new Use[3+NumArgs];
+ Use *OL = OperandList = allocHangoffUses(3+NumArgs);
OL[0].init(Fn, this);
OL[1].init(IfNormal, this);
OL[2].init(IfException, this);
@@ -414,7 +414,7 @@
InvokeInst::InvokeInst(const InvokeInst &II)
: TerminatorInst(II.getType(), Instruction::Invoke,
- new Use[II.getNumOperands()], II.getNumOperands()) {
+ allocHangoffUses(II.getNumOperands()), II.getNumOperands()) {
setParamAttrs(II.getParamAttrs());
SubclassData = II.SubclassData;
Use *OL = OperandList, *InOL = II.OperandList;
@@ -456,45 +456,45 @@
ReturnInst::ReturnInst(const ReturnInst &RI)
: TerminatorInst(Type::VoidTy, Instruction::Ret,
- &RetVal, RI.getNumOperands()) {
+ /*&RetVal*/NULL, RI.getNumOperands()) {
unsigned N = RI.getNumOperands();
if (N == 1)
- RetVal.init(RI.RetVal, this);
+ Op<0>().init(RI.Op<0>(), this);
else if (N) {
- Use *OL = OperandList = new Use[N];
+ Use *OL = OperandList = allocHangoffUses(N);
for (unsigned i = 0; i < N; ++i)
OL[i].init(RI.getOperand(i), this);
}
}
ReturnInst::ReturnInst(Value *retVal, Instruction *InsertBefore)
- : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertBefore) {
+ : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, 0, InsertBefore) {
if (retVal)
init(&retVal, 1);
}
ReturnInst::ReturnInst(Value *retVal, BasicBlock *InsertAtEnd)
- : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertAtEnd) {
+ : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, 0, InsertAtEnd) {
if (retVal)
init(&retVal, 1);
}
ReturnInst::ReturnInst(BasicBlock *InsertAtEnd)
- : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertAtEnd) {
+ : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, 0, InsertAtEnd) {
}
ReturnInst::ReturnInst(Value * const* retVals, unsigned N,
Instruction *InsertBefore)
- : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, N, InsertBefore) {
+ : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, N, InsertBefore) {
if (N != 0)
init(retVals, N);
}
ReturnInst::ReturnInst(Value * const* retVals, unsigned N,
BasicBlock *InsertAtEnd)
- : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, N, InsertAtEnd) {
+ : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, N, InsertAtEnd) {
if (N != 0)
init(retVals, N);
}
ReturnInst::ReturnInst(Value * const* retVals, unsigned N)
- : TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, N) {
+ : TerminatorInst(Type::VoidTy, Instruction::Ret, /*&RetVal*/NULL, N) {
if (N != 0)
init(retVals, N);
}
@@ -507,11 +507,10 @@
Value *V = *retVals;
if (V->getType() == Type::VoidTy)
return;
- RetVal.init(V, this);
- return;
+ Op<0>().init(V, this);
}
- Use *OL = OperandList = new Use[NumOperands];
+ Use *OL = OperandList = allocHangoffUses(NumOperands);
for (unsigned i = 0; i < NumOperands; ++i) {
Value *V = *retVals++;
assert(!isa<BasicBlock>(V) &&
@@ -537,8 +536,8 @@
}
ReturnInst::~ReturnInst() {
- if (NumOperands > 1)
- delete [] OperandList;
+// if (NumOperands > 1)
+// delete [] OperandList;
}
//===----------------------------------------------------------------------===//
@@ -603,33 +602,33 @@
}
BranchInst::BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore)
- : TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 1, InsertBefore) {
+ : TerminatorInst(Type::VoidTy, Instruction::Br, /*Ops*/NULL, 1, InsertBefore) {
assert(IfTrue != 0 && "Branch destination may not be null!");
- Ops[0].init(reinterpret_cast<Value*>(IfTrue), this);
+ Op<0>().init(reinterpret_cast<Value*>(IfTrue), this);
}
BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
Instruction *InsertBefore)
-: TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 3, InsertBefore) {
- Ops[0].init(reinterpret_cast<Value*>(IfTrue), this);
- Ops[1].init(reinterpret_cast<Value*>(IfFalse), this);
- Ops[2].init(Cond, this);
+: TerminatorInst(Type::VoidTy, Instruction::Br, /*Ops*/NULL, 3, InsertBefore) {
+ Op<0>().init(reinterpret_cast<Value*>(IfTrue), this);
+ Op<1>().init(reinterpret_cast<Value*>(IfFalse), this);
+ Op<2>().init(Cond, this);
#ifndef NDEBUG
AssertOK();
#endif
}
BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd)
- : TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 1, InsertAtEnd) {
+ : TerminatorInst(Type::VoidTy, Instruction::Br, /*Ops*/NULL, 1, InsertAtEnd) {
assert(IfTrue != 0 && "Branch destination may not be null!");
- Ops[0].init(reinterpret_cast<Value*>(IfTrue), this);
+ Op<0>().init(reinterpret_cast<Value*>(IfTrue), this);
}
BranchInst::BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
BasicBlock *InsertAtEnd)
- : TerminatorInst(Type::VoidTy, Instruction::Br, Ops, 3, InsertAtEnd) {
- Ops[0].init(reinterpret_cast<Value*>(IfTrue), this);
- Ops[1].init(reinterpret_cast<Value*>(IfFalse), this);
- Ops[2].init(Cond, this);
+ : TerminatorInst(Type::VoidTy, Instruction::Br, /*Ops*/NULL, 3, InsertAtEnd) {
+ Op<0>().init(reinterpret_cast<Value*>(IfTrue), this);
+ Op<1>().init(reinterpret_cast<Value*>(IfFalse), this);
+ Op<2>().init(Cond, this);
#ifndef NDEBUG
AssertOK();
#endif
@@ -637,7 +636,7 @@
BranchInst::BranchInst(const BranchInst &BI) :
- TerminatorInst(Type::VoidTy, Instruction::Br, Ops, BI.getNumOperands()) {
+ TerminatorInst(Type::VoidTy, Instruction::Br, /*Ops*/NULL, BI.getNumOperands()) {
OperandList[0].init(BI.getOperand(0), this);
if (BI.getNumOperands() != 1) {
assert(BI.getNumOperands() == 3 && "BR can have 1 or 3 operands!");
@@ -869,18 +868,18 @@
StoreInst::StoreInst(Value *val, Value *addr, Instruction *InsertBefore)
- : Instruction(Type::VoidTy, Store, Ops, 2, InsertBefore) {
- Ops[0].init(val, this);
- Ops[1].init(addr, this);
+ : Instruction(Type::VoidTy, Store, /*Ops*/NULL, 2, InsertBefore) {
+ Op<0>().init(val, this);
+ Op<1>().init(addr, this);
setVolatile(false);
setAlignment(0);
AssertOK();
}
StoreInst::StoreInst(Value *val, Value *addr, BasicBlock *InsertAtEnd)
- : Instruction(Type::VoidTy, Store, Ops, 2, InsertAtEnd) {
- Ops[0].init(val, this);
- Ops[1].init(addr, this);
+ : Instruction(Type::VoidTy, Store, /*Ops*/NULL, 2, InsertAtEnd) {
+ Op<0>().init(val, this);
+ Op<1>().init(addr, this);
setVolatile(false);
setAlignment(0);
AssertOK();
@@ -888,9 +887,9 @@
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
Instruction *InsertBefore)
- : Instruction(Type::VoidTy, Store, Ops, 2, InsertBefore) {
- Ops[0].init(val, this);
- Ops[1].init(addr, this);
+ : Instruction(Type::VoidTy, Store, /*Ops*/NULL, 2, InsertBefore) {
+ Op<0>().init(val, this);
+ Op<1>().init(addr, this);
setVolatile(isVolatile);
setAlignment(0);
AssertOK();
@@ -898,9 +897,9 @@
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
unsigned Align, Instruction *InsertBefore)
- : Instruction(Type::VoidTy, Store, Ops, 2, InsertBefore) {
- Ops[0].init(val, this);
- Ops[1].init(addr, this);
+ : Instruction(Type::VoidTy, Store, /*Ops*/NULL, 2, InsertBefore) {
+ Op<0>().init(val, this);
+ Op<1>().init(addr, this);
setVolatile(isVolatile);
setAlignment(Align);
AssertOK();
@@ -908,9 +907,9 @@
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
unsigned Align, BasicBlock *InsertAtEnd)
- : Instruction(Type::VoidTy, Store, Ops, 2, InsertAtEnd) {
- Ops[0].init(val, this);
- Ops[1].init(addr, this);
+ : Instruction(Type::VoidTy, Store, /*Ops*/NULL, 2, InsertAtEnd) {
+ Op<0>().init(val, this);
+ Op<1>().init(addr, this);
setVolatile(isVolatile);
setAlignment(Align);
AssertOK();
@@ -918,9 +917,9 @@
StoreInst::StoreInst(Value *val, Value *addr, bool isVolatile,
BasicBlock *InsertAtEnd)
- : Instruction(Type::VoidTy, Store, Ops, 2, InsertAtEnd) {
- Ops[0].init(val, this);
- Ops[1].init(addr, this);
+ : Instruction(Type::VoidTy, Store, /*Ops*/NULL, 2, InsertAtEnd) {
+ Op<0>().init(val, this);
+ Op<1>().init(addr, this);
setVolatile(isVolatile);
setAlignment(0);
AssertOK();
@@ -941,7 +940,7 @@
void GetElementPtrInst::init(Value *Ptr, Value* const *Idx, unsigned NumIdx) {
NumOperands = 1+NumIdx;
- Use *OL = OperandList = new Use[NumOperands];
+ Use *OL = OperandList = allocHangoffUses(NumOperands);
OL[0].init(Ptr, this);
for (unsigned i = 0; i != NumIdx; ++i)
@@ -950,7 +949,7 @@
void GetElementPtrInst::init(Value *Ptr, Value *Idx) {
NumOperands = 2;
- Use *OL = OperandList = new Use[2];
+ Use *OL = OperandList = allocHangoffUses(2);
OL[0].init(Ptr, this);
OL[1].init(Idx, this);
}
@@ -1067,11 +1066,11 @@
const std::string &Name,
Instruction *InsertBef)
: Instruction(cast<VectorType>(Val->getType())->getElementType(),
- ExtractElement, Ops, 2, InsertBef) {
+ ExtractElement, /*Ops*/NULL, 2, InsertBef) {
assert(isValidOperands(Val, Index) &&
"Invalid extractelement instruction operands!");
- Ops[0].init(Val, this);
- Ops[1].init(Index, this);
+ Op<0>().init(Val, this);
+ Op<1>().init(Index, this);
setName(Name);
}
@@ -1079,12 +1078,12 @@
const std::string &Name,
Instruction *InsertBef)
: Instruction(cast<VectorType>(Val->getType())->getElementType(),
- ExtractElement, Ops, 2, InsertBef) {
+ ExtractElement, /*Ops*/NULL, 2, InsertBef) {
Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
assert(isValidOperands(Val, Index) &&
"Invalid extractelement instruction operands!");
- Ops[0].init(Val, this);
- Ops[1].init(Index, this);
+ Op<0>().init(Val, this);
+ Op<1>().init(Index, this);
setName(Name);
}
@@ -1093,12 +1092,12 @@
const std::string &Name,
BasicBlock *InsertAE)
: Instruction(cast<VectorType>(Val->getType())->getElementType(),
- ExtractElement, Ops, 2, InsertAE) {
+ ExtractElement, /*Ops*/NULL, 2, InsertAE) {
assert(isValidOperands(Val, Index) &&
"Invalid extractelement instruction operands!");
- Ops[0].init(Val, this);
- Ops[1].init(Index, this);
+ Op<0>().init(Val, this);
+ Op<1>().init(Index, this);
setName(Name);
}
@@ -1106,13 +1105,13 @@
const std::string &Name,
BasicBlock *InsertAE)
: Instruction(cast<VectorType>(Val->getType())->getElementType(),
- ExtractElement, Ops, 2, InsertAE) {
+ ExtractElement, /*Ops*/NULL, 2, InsertAE) {
Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
assert(isValidOperands(Val, Index) &&
"Invalid extractelement instruction operands!");
- Ops[0].init(Val, this);
- Ops[1].init(Index, this);
+ Op<0>().init(Val, this);
+ Op<1>().init(Index, this);
setName(Name);
}
@@ -1129,33 +1128,33 @@
//===----------------------------------------------------------------------===//
InsertElementInst::InsertElementInst(const InsertElementInst &IE)
- : Instruction(IE.getType(), InsertElement, Ops, 3) {
- Ops[0].init(IE.Ops[0], this);
- Ops[1].init(IE.Ops[1], this);
- Ops[2].init(IE.Ops[2], this);
+ : Instruction(IE.getType(), InsertElement, /*Ops*/NULL, 3) {
+ Op<0>().init(IE.Op<0>(), this);
+ Op<1>().init(IE.Op<1>(), this);
+ Op<2>().init(IE.Op<2>(), this);
}
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
const std::string &Name,
Instruction *InsertBef)
- : Instruction(Vec->getType(), InsertElement, Ops, 3, InsertBef) {
+ : Instruction(Vec->getType(), InsertElement, /*Ops*/NULL, 3, InsertBef) {
assert(isValidOperands(Vec, Elt, Index) &&
"Invalid insertelement instruction operands!");
- Ops[0].init(Vec, this);
- Ops[1].init(Elt, this);
- Ops[2].init(Index, this);
+ Op<0>().init(Vec, this);
+ Op<1>().init(Elt, this);
+ Op<2>().init(Index, this);
setName(Name);
}
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV,
const std::string &Name,
Instruction *InsertBef)
- : Instruction(Vec->getType(), InsertElement, Ops, 3, InsertBef) {
+ : Instruction(Vec->getType(), InsertElement, /*Ops*/NULL, 3, InsertBef) {
Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
assert(isValidOperands(Vec, Elt, Index) &&
"Invalid insertelement instruction operands!");
- Ops[0].init(Vec, this);
- Ops[1].init(Elt, this);
- Ops[2].init(Index, this);
+ Op<0>().init(Vec, this);
+ Op<1>().init(Elt, this);
+ Op<2>().init(Index, this);
setName(Name);
}
@@ -1163,27 +1162,27 @@
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, Value *Index,
const std::string &Name,
BasicBlock *InsertAE)
- : Instruction(Vec->getType(), InsertElement, Ops, 3, InsertAE) {
+ : Instruction(Vec->getType(), InsertElement, /*Ops*/NULL, 3, InsertAE) {
assert(isValidOperands(Vec, Elt, Index) &&
"Invalid insertelement instruction operands!");
- Ops[0].init(Vec, this);
- Ops[1].init(Elt, this);
- Ops[2].init(Index, this);
+ Op<0>().init(Vec, this);
+ Op<1>().init(Elt, this);
+ Op<2>().init(Index, this);
setName(Name);
}
InsertElementInst::InsertElementInst(Value *Vec, Value *Elt, unsigned IndexV,
const std::string &Name,
BasicBlock *InsertAE)
-: Instruction(Vec->getType(), InsertElement, Ops, 3, InsertAE) {
+: Instruction(Vec->getType(), InsertElement, /*Ops*/NULL, 3, InsertAE) {
Constant *Index = ConstantInt::get(Type::Int32Ty, IndexV);
assert(isValidOperands(Vec, Elt, Index) &&
"Invalid insertelement instruction operands!");
- Ops[0].init(Vec, this);
- Ops[1].init(Elt, this);
- Ops[2].init(Index, this);
+ Op<0>().init(Vec, this);
+ Op<1>().init(Elt, this);
+ Op<2>().init(Index, this);
setName(Name);
}
@@ -1206,34 +1205,34 @@
//===----------------------------------------------------------------------===//
ShuffleVectorInst::ShuffleVectorInst(const ShuffleVectorInst &SV)
- : Instruction(SV.getType(), ShuffleVector, Ops, 3) {
- Ops[0].init(SV.Ops[0], this);
- Ops[1].init(SV.Ops[1], this);
- Ops[2].init(SV.Ops[2], this);
+ : Instruction(SV.getType(), ShuffleVector, /*Ops*/NULL, 3) {
+ Op<0>().init(SV.Op<0>(), this);
+ Op<1>().init(SV.Op<1>(), this);
+ Op<2>().init(SV.Op<2>(), this);
}
ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
const std::string &Name,
Instruction *InsertBefore)
- : Instruction(V1->getType(), ShuffleVector, Ops, 3, InsertBefore) {
+ : Instruction(V1->getType(), ShuffleVector, /*Ops*/NULL, 3, InsertBefore) {
assert(isValidOperands(V1, V2, Mask) &&
"Invalid shuffle vector instruction operands!");
- Ops[0].init(V1, this);
- Ops[1].init(V2, this);
- Ops[2].init(Mask, this);
+ Op<0>().init(V1, this);
+ Op<1>().init(V2, this);
+ Op<2>().init(Mask, this);
setName(Name);
}
ShuffleVectorInst::ShuffleVectorInst(Value *V1, Value *V2, Value *Mask,
const std::string &Name,
BasicBlock *InsertAtEnd)
- : Instruction(V1->getType(), ShuffleVector, Ops, 3, InsertAtEnd) {
+ : Instruction(V1->getType(), ShuffleVector, /*Ops*/NULL, 3, InsertAtEnd) {
assert(isValidOperands(V1, V2, Mask) &&
"Invalid shuffle vector instruction operands!");
- Ops[0].init(V1, this);
- Ops[1].init(V2, this);
- Ops[2].init(Mask, this);
+ Op<0>().init(V1, this);
+ Op<1>().init(V2, this);
+ Op<2>().init(Mask, this);
setName(Name);
}
@@ -1275,9 +1274,9 @@
BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
const Type *Ty, const std::string &Name,
Instruction *InsertBefore)
- : Instruction(Ty, iType, Ops, 2, InsertBefore) {
- Ops[0].init(S1, this);
- Ops[1].init(S2, this);
+ : Instruction(Ty, iType, /*Ops*/NULL, 2, InsertBefore) {
+ Op<0>().init(S1, this);
+ Op<1>().init(S2, this);
init(iType);
setName(Name);
}
@@ -1285,9 +1284,9 @@
BinaryOperator::BinaryOperator(BinaryOps iType, Value *S1, Value *S2,
const Type *Ty, const std::string &Name,
BasicBlock *InsertAtEnd)
- : Instruction(Ty, iType, Ops, 2, InsertAtEnd) {
- Ops[0].init(S1, this);
- Ops[1].init(S2, this);
+ : Instruction(Ty, iType, /*Ops*/NULL, 2, InsertAtEnd) {
+ Op<0>().init(S1, this);
+ Op<1>().init(S2, this);
init(iType);
setName(Name);
}
@@ -1482,7 +1481,7 @@
bool BinaryOperator::swapOperands() {
if (!isCommutative())
return true; // Can't commute operands
- std::swap(Ops[0], Ops[1]);
+ std::swap(Op<0>(), Op<1>());
return false;
}
@@ -2254,9 +2253,9 @@
CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS,
const std::string &Name, Instruction *InsertBefore)
- : Instruction(Type::Int1Ty, op, Ops, 2, InsertBefore) {
- Ops[0].init(LHS, this);
- Ops[1].init(RHS, this);
+ : Instruction(Type::Int1Ty, op, /*Ops*/NULL, 2, InsertBefore) {
+ Op<0>().init(LHS, this);
+ Op<1>().init(RHS, this);
SubclassData = predicate;
setName(Name);
if (op == Instruction::ICmp) {
@@ -2286,9 +2285,9 @@
CmpInst::CmpInst(OtherOps op, unsigned short predicate, Value *LHS, Value *RHS,
const std::string &Name, BasicBlock *InsertAtEnd)
- : Instruction(Type::Int1Ty, op, Ops, 2, InsertAtEnd) {
- Ops[0].init(LHS, this);
- Ops[1].init(RHS, this);
+ : Instruction(Type::Int1Ty, op, /*Ops*/NULL, 2, InsertAtEnd) {
+ Op<0>().init(LHS, this);
+ Op<1>().init(RHS, this);
SubclassData = predicate;
setName(Name);
if (op == Instruction::ICmp) {
@@ -2548,7 +2547,7 @@
assert(Value && Default);
ReservedSpace = 2+NumCases*2;
NumOperands = 2;
- OperandList = new Use[ReservedSpace];
+ OperandList = allocHangoffUses(ReservedSpace);
OperandList[0].init(Value, this);
OperandList[1].init(Default, this);
@@ -2576,7 +2575,7 @@
SwitchInst::SwitchInst(const SwitchInst &SI)
: TerminatorInst(Type::VoidTy, Instruction::Switch,
- new Use[SI.getNumOperands()], SI.getNumOperands()) {
+ allocHangoffUses(SI.getNumOperands()), SI.getNumOperands()) {
Use *OL = OperandList, *InOL = SI.OperandList;
for (unsigned i = 0, E = SI.getNumOperands(); i != E; i+=2) {
OL[i].init(InOL[i], this);
@@ -2585,7 +2584,7 @@
}
SwitchInst::~SwitchInst() {
- delete [] OperandList;
+// delete [] OperandList;
}
@@ -2649,13 +2648,13 @@
}
ReservedSpace = NumOps;
- Use *NewOps = new Use[NumOps];
+ Use *NewOps = allocHangoffUses(NumOps);
Use *OldOps = OperandList;
for (unsigned i = 0, e = getNumOperands(); i != e; ++i) {
NewOps[i].init(OldOps[i], this);
OldOps[i].set(0);
}
- delete [] OldOps;
+// delete [] OldOps;
OperandList = NewOps;
}
@@ -2678,9 +2677,9 @@
const std::string &Name,
Instruction *InsertBef)
: Instruction(cast<StructType>(Aggregate->getType())->getElementType(Index),
- GetResult, &Aggr, 1, InsertBef) {
+ GetResult, /*&Aggr*/NULL, 1, InsertBef) {
assert(isValidOperands(Aggregate, Index) && "Invalid GetResultInst operands!");
- Aggr.init(Aggregate, this);
+ Op<0>().init(Aggregate, this);
Idx = Index;
setName(Name);
}
@@ -2714,14 +2713,14 @@
}
BinaryOperator *BinaryOperator::clone() const {
- return create(getOpcode(), Ops[0], Ops[1]);
+ return create(getOpcode(), Op<0>(), Op<1>());
}
FCmpInst* FCmpInst::clone() const {
- return new FCmpInst(getPredicate(), Ops[0], Ops[1]);
+ return new FCmpInst(getPredicate(), Op<0>(), Op<1>());
}
ICmpInst* ICmpInst::clone() const {
- return new ICmpInst(getPredicate(), Ops[0], Ops[1]);
+ return new ICmpInst(getPredicate(), Op<0>(), Op<1>());
}
MallocInst *MallocInst::clone() const { return new MallocInst(*this); }
Modified: llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp?rev=49425&r1=49424&r2=49425&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Use.cpp Wed Apr 9 09:39:56 2008
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
//
-// This file implements the algoritm for finding the User of a Use.
+// This file implements the algorithm for finding the User of a Use.
//
//===----------------------------------------------------------------------===//
More information about the llvm-commits
mailing list