[llvm-commits] [llvm] r49626 - /llvm/branches/ggreif/use-diet/include/llvm/Instructions.h
Gabor Greif
ggreif at gmail.com
Sun Apr 13 15:51:07 PDT 2008
Author: ggreif
Date: Sun Apr 13 17:51:07 2008
New Revision: 49626
URL: http://llvm.org/viewvc/llvm-project?rev=49626&view=rev
Log:
cope with BranchInst's possibly shrinking operand list
Modified:
llvm/branches/ggreif/use-diet/include/llvm/Instructions.h
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=49626&r1=49625&r2=49626&view=diff
==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Sun Apr 13 17:51:07 2008
@@ -1698,7 +1698,13 @@
return new(3) BranchInst(IfTrue, IfFalse, Cond, InsertAtEnd);
}
- // not yet ~BranchInst();
+ ~BranchInst()
+ {
+ if (NumOperands == 1)
+ {
+ NumOperands = (Use*)this - OperandList;
+ }
+ }
/// Transparently provide more efficient getOperand methods.
DECLARE_TRANSPARENT_OPERAND_ACCESSORS(Value);
@@ -1722,12 +1728,12 @@
// targeting the specified block.
// FIXME: Eliminate this ugly method.
void setUnconditionalDest(BasicBlock *Dest) {
+ Op<0>() = Dest;
if (isConditional()) { // Convert this to an uncond branch.
- NumOperands = 1;
Op<1>().set(0);
Op<2>().set(0);
+ NumOperands = 1;
}
- Op<0>() = Dest;
}
unsigned getNumSuccessors() const { return 1+isConditional(); }
@@ -1757,7 +1763,10 @@
};
template <>
-struct OperandTraits<BranchInst> : VariadicOperandTraits<1> {
+struct OperandTraits<BranchInst> : HungoffOperandTraits<> {
+ // we need to access operands via OperandList, since
+ // the NumOperands may change from 3 to 1
+ static inline void *allocate(unsigned); // FIXME
};
DEFINE_TRANSPARENT_OPERAND_ACCESSORS(BranchInst, Value)
More information about the llvm-commits
mailing list