aboutsummaryrefslogtreecommitdiffstats
path: root/lib/VMCore/Constants.cpp
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-06-23 16:39:44 +0000
committerDan Gohman <gohman@apple.com>2008-06-23 16:39:44 +0000
commit1a203571ca94c4770a8cada8ace7fbeb0e65799a (patch)
tree092eee8aa69ae9dbbcd22bf87d1262e01e3e902a /lib/VMCore/Constants.cpp
parent19a81633b01b4b30b356ba6d7aed6bc451470654 (diff)
downloadexternal_llvm-1a203571ca94c4770a8cada8ace7fbeb0e65799a.zip
external_llvm-1a203571ca94c4770a8cada8ace7fbeb0e65799a.tar.gz
external_llvm-1a203571ca94c4770a8cada8ace7fbeb0e65799a.tar.bz2
More changes from Chris' review: simplify getIndices and avoid
copying its return value. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@52627 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/VMCore/Constants.cpp')
-rw-r--r--lib/VMCore/Constants.cpp14
1 files changed, 6 insertions, 8 deletions
diff --git a/lib/VMCore/Constants.cpp b/lib/VMCore/Constants.cpp
index 530f7ba..e6398a3 100644
--- a/lib/VMCore/Constants.cpp
+++ b/lib/VMCore/Constants.cpp
@@ -712,10 +712,8 @@ const SmallVector<unsigned, 4> &ConstantExpr::getIndices() const {
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 @@ ConstantExpr::getWithOperandReplaced(unsigned OpNo, Constant *Op) const {
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 @@ ConstantExpr::getWithOperandReplaced(unsigned OpNo, Constant *Op) const {
}
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 @@ getWithOperands(const std::vector<Constant*> &Ops) const {
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());
}