[llvm-commits] CVS: llvm/lib/VMCore/Instruction.cpp Instructions.cpp
Chris Lattner
sabre at nondot.org
Mon Feb 12 23:55:02 PST 2007
Changes in directory llvm/lib/VMCore:
Instruction.cpp updated: 1.64 -> 1.65
Instructions.cpp updated: 1.74 -> 1.75
---
Log message:
Switch UnaryOperators to default to passing names up by const char* when possible.
This speeds up bcreading by 1.5%.
---
Diffs of the changes: (+74 -8)
Instruction.cpp | 28 ++++++++++++++++++++++++++++
Instructions.cpp | 54 ++++++++++++++++++++++++++++++++++++++++++++++--------
2 files changed, 74 insertions(+), 8 deletions(-)
Index: llvm/lib/VMCore/Instruction.cpp
diff -u llvm/lib/VMCore/Instruction.cpp:1.64 llvm/lib/VMCore/Instruction.cpp:1.65
--- llvm/lib/VMCore/Instruction.cpp:1.64 Sun Feb 11 23:18:08 2007
+++ llvm/lib/VMCore/Instruction.cpp Tue Feb 13 01:54:42 2007
@@ -44,6 +44,34 @@
setName(Name);
}
+Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
+ const char *Name, Instruction *InsertBefore)
+ : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
+ // Make sure that we get added to a basicblock
+ LeakDetector::addGarbageObject(this);
+
+ // If requested, insert this instruction into a basic block...
+ if (InsertBefore) {
+ assert(InsertBefore->getParent() &&
+ "Instruction to insert before is not in a basic block!");
+ InsertBefore->getParent()->getInstList().insert(InsertBefore, this);
+ }
+ if (Name && *Name) setName(Name);
+}
+
+Instruction::Instruction(const Type *ty, unsigned it, Use *Ops, unsigned NumOps,
+ const char *Name, BasicBlock *InsertAtEnd)
+ : User(ty, Value::InstructionVal + it, Ops, NumOps), Parent(0) {
+ // Make sure that we get added to a basicblock
+ LeakDetector::addGarbageObject(this);
+
+ // append this instruction into the basic block
+ assert(InsertAtEnd && "Basic block to append to may not be NULL!");
+ InsertAtEnd->getInstList().push_back(this);
+ if (Name && *Name) setName(Name);
+}
+
+
// Out of line virtual method, so the vtable, etc has a home.
Instruction::~Instruction() {
assert(Parent == 0 && "Instruction still linked in the program!");
Index: llvm/lib/VMCore/Instructions.cpp
diff -u llvm/lib/VMCore/Instructions.cpp:1.74 llvm/lib/VMCore/Instructions.cpp:1.75
--- llvm/lib/VMCore/Instructions.cpp:1.74 Tue Feb 13 00:22:32 2007
+++ llvm/lib/VMCore/Instructions.cpp Tue Feb 13 01:54:42 2007
@@ -531,18 +531,20 @@
unsigned Align, const std::string &Name,
Instruction *InsertBefore)
: UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize),
- Name, InsertBefore), Alignment(Align) {
+ 0, InsertBefore), Alignment(Align) {
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
assert(Ty != Type::VoidTy && "Cannot allocate void!");
+ setName(Name);
}
AllocationInst::AllocationInst(const Type *Ty, Value *ArraySize, unsigned iTy,
unsigned Align, const std::string &Name,
BasicBlock *InsertAtEnd)
: UnaryInstruction(PointerType::get(Ty), iTy, getAISize(ArraySize),
- Name, InsertAtEnd), Alignment(Align) {
+ 0, InsertAtEnd), Alignment(Align) {
assert((Align & (Align-1)) == 0 && "Alignment is not a power of 2!");
assert(Ty != Type::VoidTy && "Cannot allocate void!");
+ setName(Name);
}
// Out of line virtual method, so the vtable, etc has a home.
@@ -579,12 +581,12 @@
}
FreeInst::FreeInst(Value *Ptr, Instruction *InsertBefore)
- : UnaryInstruction(Type::VoidTy, Free, Ptr, "", InsertBefore) {
+ : UnaryInstruction(Type::VoidTy, Free, Ptr, 0, InsertBefore) {
AssertOK();
}
FreeInst::FreeInst(Value *Ptr, BasicBlock *InsertAtEnd)
- : UnaryInstruction(Type::VoidTy, Free, Ptr, "", InsertAtEnd) {
+ : UnaryInstruction(Type::VoidTy, Free, Ptr, 0, InsertAtEnd) {
AssertOK();
}
@@ -600,30 +602,66 @@
LoadInst::LoadInst(Value *Ptr, const std::string &Name, Instruction *InsertBef)
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
- Load, Ptr, Name, InsertBef) {
+ Load, Ptr, 0, InsertBef) {
setVolatile(false);
AssertOK();
+ setName(Name);
}
LoadInst::LoadInst(Value *Ptr, const std::string &Name, BasicBlock *InsertAE)
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
- Load, Ptr, Name, InsertAE) {
+ Load, Ptr, 0, InsertAE) {
setVolatile(false);
AssertOK();
+ setName(Name);
}
LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
Instruction *InsertBef)
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
- Load, Ptr, Name, InsertBef) {
+ Load, Ptr, 0, InsertBef) {
setVolatile(isVolatile);
AssertOK();
+ setName(Name);
}
LoadInst::LoadInst(Value *Ptr, const std::string &Name, bool isVolatile,
BasicBlock *InsertAE)
: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
- Load, Ptr, Name, InsertAE) {
+ Load, Ptr, 0, InsertAE) {
+ setVolatile(isVolatile);
+ AssertOK();
+ setName(Name);
+}
+
+
+
+LoadInst::LoadInst(Value *Ptr, const char *Name, Instruction *InsertBef)
+: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
+ Load, Ptr, Name, InsertBef) {
+ setVolatile(false);
+ AssertOK();
+}
+
+LoadInst::LoadInst(Value *Ptr, const char *Name, BasicBlock *InsertAE)
+: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
+ Load, Ptr, Name, InsertAE) {
+ setVolatile(false);
+ AssertOK();
+}
+
+LoadInst::LoadInst(Value *Ptr, const char *Name, bool isVolatile,
+ Instruction *InsertBef)
+: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
+ Load, Ptr, Name, InsertBef) {
+ setVolatile(isVolatile);
+ AssertOK();
+}
+
+LoadInst::LoadInst(Value *Ptr, const char *Name, bool isVolatile,
+ BasicBlock *InsertAE)
+: UnaryInstruction(cast<PointerType>(Ptr->getType())->getElementType(),
+ Load, Ptr, Name, InsertAE) {
setVolatile(isVolatile);
AssertOK();
}
More information about the llvm-commits
mailing list