[llvm-commits] CVS: llvm/include/llvm/InstrTypes.h Instruction.h Instructions.h
Chris Lattner
sabre at nondot.org
Fri Feb 23 16:56:10 PST 2007
Changes in directory llvm/include/llvm:
InstrTypes.h updated: 1.62 -> 1.63
Instruction.h updated: 1.81 -> 1.82
Instructions.h updated: 1.61 -> 1.62
---
Log message:
Refactor the setName stuff, moving it down the inheritance hierarchy, to
solve a crash in -instcombine -debug that was hit while investigating PR1217: http://llvm.org/PR1217
---
Diffs of the changes: (+42 -116)
InstrTypes.h | 46 +++++++------------------
Instruction.h | 8 +---
Instructions.h | 104 ++++++++++++++-------------------------------------------
3 files changed, 42 insertions(+), 116 deletions(-)
Index: llvm/include/llvm/InstrTypes.h
diff -u llvm/include/llvm/InstrTypes.h:1.62 llvm/include/llvm/InstrTypes.h:1.63
--- llvm/include/llvm/InstrTypes.h:1.62 Tue Feb 13 03:26:04 2007
+++ llvm/include/llvm/InstrTypes.h Fri Feb 23 18:55:48 2007
@@ -29,19 +29,14 @@
///
class TerminatorInst : public Instruction {
protected:
- TerminatorInst(Instruction::TermOps iType, Use *Ops, unsigned NumOps,
- Instruction *InsertBefore = 0);
TerminatorInst(const Type *Ty, Instruction::TermOps iType,
- Use *Ops, unsigned NumOps,
- const std::string &Name = "", Instruction *InsertBefore = 0)
- : Instruction(Ty, iType, Ops, NumOps, Name, InsertBefore) {}
+ Use *Ops, unsigned NumOps,
+ Instruction *InsertBefore = 0)
+ : Instruction(Ty, iType, Ops, NumOps, InsertBefore) {}
- TerminatorInst(Instruction::TermOps iType, Use *Ops, unsigned NumOps,
- BasicBlock *InsertAtEnd);
TerminatorInst(const Type *Ty, Instruction::TermOps iType,
- Use *Ops, unsigned NumOps,
- const std::string &Name, BasicBlock *InsertAtEnd)
- : Instruction(Ty, iType, Ops, NumOps, Name, InsertAtEnd) {}
+ Use *Ops, unsigned NumOps, BasicBlock *InsertAtEnd)
+ : Instruction(Ty, iType, Ops, NumOps, InsertAtEnd) {}
// Out of line virtual method, so the vtable, etc has a home.
~TerminatorInst();
@@ -90,13 +85,11 @@
class UnaryInstruction : public Instruction {
Use Op;
protected:
- UnaryInstruction(const Type *Ty, unsigned iType, Value *V,
- const char *Name = 0, Instruction *IB = 0)
- : Instruction(Ty, iType, &Op, 1, Name, IB), Op(V, this) {
- }
- UnaryInstruction(const Type *Ty, unsigned iType, Value *V,
- const char *Name, BasicBlock *IAE)
- : Instruction(Ty, iType, &Op, 1, Name, IAE), Op(V, this) {
+ 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, BasicBlock *IAE)
+ : Instruction(Ty, iType, &Op, 1, IAE), Op(V, this) {
}
public:
// Out of line virtual method, so the vtable, etc has a home.
@@ -123,20 +116,9 @@
protected:
void init(BinaryOps iType);
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
- const std::string &Name, Instruction *InsertBefore)
- : Instruction(Ty, iType, Ops, 2, Name, InsertBefore) {
- Ops[0].init(S1, this);
- Ops[1].init(S2, this);
- init(iType);
- }
+ const std::string &Name, Instruction *InsertBefore);
BinaryOperator(BinaryOps iType, Value *S1, Value *S2, const Type *Ty,
- const std::string &Name, BasicBlock *InsertAtEnd)
- : Instruction(Ty, iType, Ops, 2, Name, InsertAtEnd) {
- Ops[0].init(S1, this);
- Ops[1].init(S2, this);
- init(iType);
- }
-
+ const std::string &Name, BasicBlock *InsertAtEnd);
public:
/// Transparently provide more efficient getOperand methods.
@@ -264,13 +246,13 @@
/// @brief Constructor with insert-before-instruction semantics for subclasses
CastInst(const Type *Ty, unsigned iType, Value *S,
const std::string &Name = "", Instruction *InsertBefore = 0)
- : UnaryInstruction(Ty, iType, S, 0, InsertBefore) {
+ : UnaryInstruction(Ty, iType, S, InsertBefore) {
setName(Name);
}
/// @brief Constructor with insert-at-end-of-block semantics for subclasses
CastInst(const Type *Ty, unsigned iType, Value *S,
const std::string &Name, BasicBlock *InsertAtEnd)
- : UnaryInstruction(Ty, iType, S, 0, InsertAtEnd) {
+ : UnaryInstruction(Ty, iType, S, InsertAtEnd) {
setName(Name);
}
public:
Index: llvm/include/llvm/Instruction.h
diff -u llvm/include/llvm/Instruction.h:1.81 llvm/include/llvm/Instruction.h:1.82
--- llvm/include/llvm/Instruction.h:1.81 Thu Feb 15 17:15:00 2007
+++ llvm/include/llvm/Instruction.h Fri Feb 23 18:55:48 2007
@@ -41,13 +41,9 @@
void setParent(BasicBlock *P);
protected:
Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
- const std::string &Name, Instruction *InsertBefore = 0);
+ Instruction *InsertBefore = 0);
Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
- const std::string &Name, BasicBlock *InsertAtEnd);
- Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
- const char *Name = 0, Instruction *InsertBefore = 0);
- Instruction(const Type *Ty, unsigned iType, Use *Ops, unsigned NumOps,
- const char *Name, BasicBlock *InsertAtEnd);
+ BasicBlock *InsertAtEnd);
public:
// Out of line virtual method, so the vtable, etc has a home.
~Instruction();
Index: llvm/include/llvm/Instructions.h
diff -u llvm/include/llvm/Instructions.h:1.61 llvm/include/llvm/Instructions.h:1.62
--- llvm/include/llvm/Instructions.h:1.61 Thu Feb 15 17:15:00 2007
+++ llvm/include/llvm/Instructions.h Fri Feb 23 18:55:48 2007
@@ -773,15 +773,15 @@
public:
SelectInst(Value *C, Value *S1, Value *S2, const std::string &Name = "",
Instruction *InsertBefore = 0)
- : Instruction(S1->getType(), Instruction::Select, Ops, 3,
- Name, InsertBefore) {
+ : Instruction(S1->getType(), Instruction::Select, Ops, 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,
- Name, InsertAtEnd) {
+ : Instruction(S1->getType(), Instruction::Select, Ops, 3, InsertAtEnd) {
init(C, S1, S2);
+ setName(Name);
}
Value *getCondition() const { return Ops[0]; }
@@ -828,12 +828,12 @@
public:
VAArgInst(Value *List, const Type *Ty, const std::string &Name = "",
Instruction *InsertBefore = 0)
- : UnaryInstruction(Ty, VAArg, List, 0, InsertBefore) {
+ : UnaryInstruction(Ty, VAArg, List, InsertBefore) {
setName(Name);
}
VAArgInst(Value *List, const Type *Ty, const std::string &Name,
BasicBlock *InsertAtEnd)
- : UnaryInstruction(Ty, VAArg, List, 0, InsertAtEnd) {
+ : UnaryInstruction(Ty, VAArg, List, InsertAtEnd) {
setName(Name);
}
@@ -1022,13 +1022,15 @@
public:
explicit PHINode(const Type *Ty, const std::string &Name = "",
Instruction *InsertBefore = 0)
- : Instruction(Ty, Instruction::PHI, 0, 0, Name, InsertBefore),
+ : Instruction(Ty, Instruction::PHI, 0, 0, InsertBefore),
ReservedSpace(0) {
+ setName(Name);
}
PHINode(const Type *Ty, const std::string &Name, BasicBlock *InsertAtEnd)
- : Instruction(Ty, Instruction::PHI, 0, 0, Name, InsertAtEnd),
+ : Instruction(Ty, Instruction::PHI, 0, 0, InsertAtEnd),
ReservedSpace(0) {
+ setName(Name);
}
~PHINode();
@@ -1143,13 +1145,8 @@
/// does not continue in this function any longer.
///
class ReturnInst : public TerminatorInst {
- Use RetVal; // Possibly null retval.
- ReturnInst(const ReturnInst &RI) : TerminatorInst(Instruction::Ret, &RetVal,
- RI.getNumOperands()) {
- if (RI.getNumOperands())
- RetVal.init(RI.RetVal, this);
- }
-
+ Use RetVal; // Return Value: null if 'void'.
+ ReturnInst(const ReturnInst &RI);
void init(Value *RetVal);
public:
@@ -1164,17 +1161,9 @@
//
// NOTE: If the Value* passed is of type void then the constructor behaves as
// if it was passed NULL.
- explicit ReturnInst(Value *retVal = 0, Instruction *InsertBefore = 0)
- : TerminatorInst(Instruction::Ret, &RetVal, 0, InsertBefore) {
- init(retVal);
- }
- ReturnInst(Value *retVal, BasicBlock *InsertAtEnd)
- : TerminatorInst(Instruction::Ret, &RetVal, 0, InsertAtEnd) {
- init(retVal);
- }
- explicit ReturnInst(BasicBlock *InsertAtEnd)
- : TerminatorInst(Instruction::Ret, &RetVal, 0, InsertAtEnd) {
- }
+ explicit ReturnInst(Value *retVal = 0, Instruction *InsertBefore = 0);
+ ReturnInst(Value *retVal, BasicBlock *InsertAtEnd);
+ explicit ReturnInst(BasicBlock *InsertAtEnd);
virtual ReturnInst *clone() const;
@@ -1228,39 +1217,12 @@
// BranchInst(BB* T, BB *F, Value *C, Inst *I) - 'br C, T, F', insert before I
// BranchInst(BB* B, BB *I) - 'br B' insert at end
// BranchInst(BB* T, BB *F, Value *C, BB *I) - 'br C, T, F', insert at end
- explicit BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore = 0)
- : TerminatorInst(Instruction::Br, Ops, 1, InsertBefore) {
- assert(IfTrue != 0 && "Branch destination may not be null!");
- Ops[0].init(reinterpret_cast<Value*>(IfTrue), this);
- }
+ explicit BranchInst(BasicBlock *IfTrue, Instruction *InsertBefore = 0);
BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
- Instruction *InsertBefore = 0)
- : TerminatorInst(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);
-#ifndef NDEBUG
- AssertOK();
-#endif
- }
-
- BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd)
- : TerminatorInst(Instruction::Br, Ops, 1, InsertAtEnd) {
- assert(IfTrue != 0 && "Branch destination may not be null!");
- Ops[0].init(reinterpret_cast<Value*>(IfTrue), this);
- }
-
+ Instruction *InsertBefore = 0);
+ BranchInst(BasicBlock *IfTrue, BasicBlock *InsertAtEnd);
BranchInst(BasicBlock *IfTrue, BasicBlock *IfFalse, Value *Cond,
- BasicBlock *InsertAtEnd)
- : TerminatorInst(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);
-#ifndef NDEBUG
- AssertOK();
-#endif
- }
-
+ BasicBlock *InsertAtEnd);
/// Transparently provide more efficient getOperand methods.
Value *getOperand(unsigned i) const {
@@ -1348,20 +1310,14 @@
/// be specified here to make memory allocation more efficient. This
/// constructor can also autoinsert before another instruction.
SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases,
- Instruction *InsertBefore = 0)
- : TerminatorInst(Instruction::Switch, 0, 0, InsertBefore) {
- init(Value, Default, NumCases);
- }
-
+ Instruction *InsertBefore = 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
/// constructor also autoinserts at the end of the specified BasicBlock.
SwitchInst(Value *Value, BasicBlock *Default, unsigned NumCases,
- BasicBlock *InsertAtEnd)
- : TerminatorInst(Instruction::Switch, 0, 0, InsertAtEnd) {
- init(Value, Default, NumCases);
- }
+ BasicBlock *InsertAtEnd);
~SwitchInst();
@@ -1554,12 +1510,8 @@
///
class UnwindInst : public TerminatorInst {
public:
- explicit UnwindInst(Instruction *InsertBefore = 0)
- : TerminatorInst(Instruction::Unwind, 0, 0, InsertBefore) {
- }
- explicit UnwindInst(BasicBlock *InsertAtEnd)
- : TerminatorInst(Instruction::Unwind, 0, 0, InsertAtEnd) {
- }
+ explicit UnwindInst(Instruction *InsertBefore = 0);
+ explicit UnwindInst(BasicBlock *InsertAtEnd);
virtual UnwindInst *clone() const;
@@ -1590,12 +1542,8 @@
///
class UnreachableInst : public TerminatorInst {
public:
- explicit UnreachableInst(Instruction *InsertBefore = 0)
- : TerminatorInst(Instruction::Unreachable, 0, 0, InsertBefore) {
- }
- explicit UnreachableInst(BasicBlock *InsertAtEnd)
- : TerminatorInst(Instruction::Unreachable, 0, 0, InsertAtEnd) {
- }
+ explicit UnreachableInst(Instruction *InsertBefore = 0);
+ explicit UnreachableInst(BasicBlock *InsertAtEnd);
virtual UnreachableInst *clone() const;
More information about the llvm-commits
mailing list