[llvm-commits] [llvm] r49739 - in /llvm/branches/ggreif/use-diet: include/llvm/Instructions.h lib/VMCore/Instructions.cpp

Gabor Greif ggreif at gmail.com
Tue Apr 15 13:58:01 PDT 2008


Author: ggreif
Date: Tue Apr 15 15:58:01 2008
New Revision: 49739

URL: http://llvm.org/viewvc/llvm-project?rev=49739&view=rev
Log:
make sure that SwitchInst's operands are always hung off

Modified:
    llvm/branches/ggreif/use-diet/include/llvm/Instructions.h
    llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp

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=49739&r1=49738&r2=49739&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/include/llvm/Instructions.h (original)
+++ llvm/branches/ggreif/use-diet/include/llvm/Instructions.h Tue Apr 15 15:58:01 2008
@@ -1754,6 +1754,7 @@
 /// SwitchInst - Multiway switch
 ///
 class SwitchInst : public TerminatorInst {
+  void *operator new(size_t, unsigned);  // DO NOT IMPLEMENT
   unsigned ReservedSpace;
   // Operand[0]    = Value to switch on
   // Operand[1]    = Default basic block destination
@@ -1762,6 +1763,10 @@
   SwitchInst(const SwitchInst &RI);
   void init(Value *Value, BasicBlock *Default, unsigned NumCases);
   void resizeOperands(unsigned No);
+  // allocate space for exactly zero operands
+  void *operator new(size_t s) {
+    return User::operator new(s, 0);
+  }
   /// SwitchInst ctor - Create a new switch instruction, specifying a value to
   /// switch on and a default destination.  The number of additional cases can
   /// be specified here to make memory allocation more efficient.  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=49739&r1=49738&r2=49739&view=diff

==============================================================================
--- llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp (original)
+++ llvm/branches/ggreif/use-diet/lib/VMCore/Instructions.cpp Tue Apr 15 15:58:01 2008
@@ -2843,7 +2843,7 @@
 PHINode    *PHINode::clone()    const { return new PHINode(*this); }
 ReturnInst *ReturnInst::clone() const { return new(getNumOperands()) ReturnInst(*this); }
 BranchInst *BranchInst::clone() const { return new(getNumOperands()) BranchInst(*this); }
-SwitchInst *SwitchInst::clone() const { return new(getNumOperands()) SwitchInst(*this); }
+SwitchInst *SwitchInst::clone() const { return new SwitchInst(*this); }
 InvokeInst *InvokeInst::clone() const { return new(getNumOperands()) InvokeInst(*this); }
 UnwindInst *UnwindInst::clone() const { return new UnwindInst(); }
 UnreachableInst *UnreachableInst::clone() const { return new UnreachableInst();}





More information about the llvm-commits mailing list