[llvm-commits] [llvm] r52627 - /llvm/trunk/lib/VMCore/Constants.cpp
Dan Gohman
gohman at apple.com
Mon Jun 23 09:39:44 PDT 2008
Author: djg
Date: Mon Jun 23 11:39:44 2008
New Revision: 52627
URL: http://llvm.org/viewvc/llvm-project?rev=52627&view=rev
Log:
More changes from Chris' review: simplify getIndices and avoid
copying its return value.
Modified:
llvm/trunk/lib/VMCore/Constants.cpp
Modified: llvm/trunk/lib/VMCore/Constants.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Constants.cpp?rev=52627&r1=52626&r2=52627&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/Constants.cpp (original)
+++ llvm/trunk/lib/VMCore/Constants.cpp Mon Jun 23 11:39:44 2008
@@ -712,10 +712,8 @@
if (const ExtractValueConstantExpr *EVCE =
dyn_cast<ExtractValueConstantExpr>(this))
return EVCE->Indices;
- if (const InsertValueConstantExpr *IVCE =
- dyn_cast<InsertValueConstantExpr>(this))
- return IVCE->Indices;
- assert(0 && "ConstantExpr does not have indices!");
+
+ return cast<InsertValueConstantExpr>(this)->Indices;
}
/// ConstantExpr::get* - Return some common constants without having to
@@ -829,7 +827,7 @@
Op2 = (OpNo == 2) ? Op : getOperand(2);
return ConstantExpr::getShuffleVector(Op0, Op1, Op2);
case Instruction::InsertValue: {
- const SmallVector<unsigned, 4> Indices = getIndices();
+ const SmallVector<unsigned, 4> &Indices = getIndices();
Op0 = (OpNo == 0) ? Op : getOperand(0);
Op1 = (OpNo == 1) ? Op : getOperand(1);
return ConstantExpr::getInsertValue(Op0, Op1,
@@ -837,7 +835,7 @@
}
case Instruction::ExtractValue: {
assert(OpNo == 0 && "ExtractaValue has only one operand!");
- const SmallVector<unsigned, 4> Indices = getIndices();
+ const SmallVector<unsigned, 4> &Indices = getIndices();
return
ConstantExpr::getExtractValue(Op, &Indices[0], Indices.size());
}
@@ -897,12 +895,12 @@
case Instruction::ShuffleVector:
return ConstantExpr::getShuffleVector(Ops[0], Ops[1], Ops[2]);
case Instruction::InsertValue: {
- const SmallVector<unsigned, 4> Indices = getIndices();
+ const SmallVector<unsigned, 4> &Indices = getIndices();
return ConstantExpr::getInsertValue(Ops[0], Ops[1],
&Indices[0], Indices.size());
}
case Instruction::ExtractValue: {
- const SmallVector<unsigned, 4> Indices = getIndices();
+ const SmallVector<unsigned, 4> &Indices = getIndices();
return ConstantExpr::getExtractValue(Ops[0],
&Indices[0], Indices.size());
}
More information about the llvm-commits
mailing list