[llvm-commits] [llvm] r47611 - in /llvm/trunk: include/llvm/Instructions.h lib/VMCore/Instructions.cpp
Devang Patel
dpatel at apple.com
Tue Feb 26 10:49:29 PST 2008
Author: dpatel
Date: Tue Feb 26 12:49:29 2008
New Revision: 47611
URL: http://llvm.org/viewvc/llvm-project?rev=47611&view=rev
Log:
Unify to ReturnInst::init() member functions.
Modified:
llvm/trunk/include/llvm/Instructions.h
llvm/trunk/lib/VMCore/Instructions.cpp
Modified: llvm/trunk/include/llvm/Instructions.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Instructions.h?rev=47611&r1=47610&r2=47611&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Instructions.h (original)
+++ llvm/trunk/include/llvm/Instructions.h Tue Feb 26 12:49:29 2008
@@ -1381,8 +1381,7 @@
class ReturnInst : public TerminatorInst {
Use RetVal;
ReturnInst(const ReturnInst &RI);
- void init(Value *RetVal);
- void init(const std::vector<Value *> &RetVals);
+ void init(const Value * const* retVals, unsigned N);
public:
// ReturnInst constructors:
Modified: llvm/trunk/lib/VMCore/Instructions.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Instructions.cpp?rev=47611&r1=47610&r2=47611&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Instructions.cpp (original)
+++ llvm/trunk/lib/VMCore/Instructions.cpp Tue Feb 26 12:49:29 2008
@@ -586,11 +586,13 @@
ReturnInst::ReturnInst(Value *retVal, Instruction *InsertBefore)
: TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertBefore) {
- init(retVal);
+ if (retVal)
+ init(&retVal, 1);
}
ReturnInst::ReturnInst(Value *retVal, BasicBlock *InsertAtEnd)
: TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertAtEnd) {
- init(retVal);
+ if (retVal)
+ init(&retVal, 1);
}
ReturnInst::ReturnInst(BasicBlock *InsertAtEnd)
: TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, 0, InsertAtEnd) {
@@ -600,48 +602,41 @@
Instruction *InsertBefore)
: TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, retVals.size(),
InsertBefore) {
- init(retVals);
+ if (!retVals.empty())
+ init(&retVals[0], retVals.size());
}
ReturnInst::ReturnInst(const std::vector<Value *> &retVals,
BasicBlock *InsertAtEnd)
: TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, retVals.size(),
InsertAtEnd) {
- init(retVals);
+ if (!retVals.empty())
+ init(&retVals[0], retVals.size());
}
ReturnInst::ReturnInst(const std::vector<Value *> &retVals)
: TerminatorInst(Type::VoidTy, Instruction::Ret, &RetVal, retVals.size()) {
- init(retVals);
+ if (!retVals.empty())
+ init(&retVals[0], retVals.size());
}
-void ReturnInst::init(Value *retVal) {
- if (retVal && retVal->getType() != Type::VoidTy) {
- assert(!isa<BasicBlock>(retVal) &&
- "Cannot return basic block. Probably using the incorrect ctor");
- NumOperands = 1;
- RetVal.init(retVal, this);
- }
-}
+void ReturnInst::init(const Value * const* retVals, unsigned N) {
-void ReturnInst::init(const std::vector<Value *> &retVals) {
- if (retVals.empty())
- return;
+ assert (N > 0 && "Invalid operands numbers in ReturnInst init");
- NumOperands = retVals.size();
+ NumOperands = N;
if (NumOperands == 1) {
- Value *V = retVals[0];
+ const Value *V = *retVals;
if (V->getType() == Type::VoidTy)
return;
- RetVal.init(V, this);
+ RetVal.init(const_cast<Value*>(V), this);
return;
}
Use *OL = OperandList = new Use[NumOperands];
- RetVal.init(retVals[0], this);
for (unsigned i = 0; i < NumOperands; ++i) {
- Value *V = retVals[i];
+ const Value *V = *retVals++;
assert(!isa<BasicBlock>(V) &&
"Cannot return basic block. Probably using the incorrect ctor");
- OL[i].init(V, this);
+ OL[i].init(const_cast<Value *>(V), this);
}
}
More information about the llvm-commits
mailing list