summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2008-05-31 19:09:08 +0000
committerDan Gohman <gohman@apple.com>2008-05-31 19:09:08 +0000
commit7bb04509f2ae5af10b336de76e52673872a3fc3e (patch)
tree82cc15c55cc89aa35566fee4d6518eba4d5af3f1
parent035fe6f716103e663b32e875f541ce3e75506bef (diff)
downloadbcm5719-llvm-7bb04509f2ae5af10b336de76e52673872a3fc3e.tar.gz
bcm5719-llvm-7bb04509f2ae5af10b336de76e52673872a3fc3e.zip
Fix some bugs with the handling of indices in insertvalue/extractvalue.
llvm-svn: 51820
-rw-r--r--llvm/include/llvm/Instructions.h20
-rw-r--r--llvm/lib/VMCore/Constants.cpp6
2 files changed, 11 insertions, 15 deletions
diff --git a/llvm/include/llvm/Instructions.h b/llvm/include/llvm/Instructions.h
index 2e69243adbe..9393ec4953e 100644
--- a/llvm/include/llvm/Instructions.h
+++ b/llvm/include/llvm/Instructions.h
@@ -1590,10 +1590,8 @@ public:
}
static const Type *getIndexedType(const Type *Ptr, unsigned Idx);
- inline op_iterator idx_begin() { return op_begin()+1; }
- inline const_op_iterator idx_begin() const { return op_begin()+1; }
- inline op_iterator idx_end() { return op_end(); }
- inline const_op_iterator idx_end() const { return op_end(); }
+ inline const unsigned *idx_begin() const { return Indices.begin(); }
+ inline const unsigned *idx_end() const { return Indices.end(); }
Value *getAggregateOperand() {
return getOperand(0);
@@ -1606,11 +1604,11 @@ public:
}
unsigned getNumIndices() const { // Note: always non-negative
- return getNumOperands() - 1;
+ return Indices.size();
}
bool hasIndices() const {
- return getNumOperands() > 1;
+ return true;
}
// Methods for support type inquiry through isa, cast, and dyn_cast:
@@ -1762,10 +1760,8 @@ public:
return reinterpret_cast<const PointerType*>(Instruction::getType());
}
- inline unsigned *idx_begin() { return Indices.begin(); }
- inline const unsigned *idx_begin() const { return Indices.begin(); }
- inline unsigned *idx_end() { return Indices.end(); }
- inline const unsigned *idx_end() const { return Indices.end(); }
+ inline const unsigned *idx_begin() const { return Indices.begin(); }
+ inline const unsigned *idx_end() const { return Indices.end(); }
Value *getAggregateOperand() {
return getOperand(0);
@@ -1788,11 +1784,11 @@ public:
}
unsigned getNumIndices() const { // Note: always non-negative
- return getNumOperands() - 2;
+ return Indices.size();
}
bool hasIndices() const {
- return getNumOperands() > 2;
+ return true;
}
// Methods for support type inquiry through isa, cast, and dyn_cast:
diff --git a/llvm/lib/VMCore/Constants.cpp b/llvm/lib/VMCore/Constants.cpp
index e15e68a73d5..9c10e75c8df 100644
--- a/llvm/lib/VMCore/Constants.cpp
+++ b/llvm/lib/VMCore/Constants.cpp
@@ -551,7 +551,7 @@ public:
Op<0>() = Agg;
}
- /// Indicies - These identify which value to extract.
+ /// Indices - These identify which value to extract.
const SmallVector<unsigned, 4> Indices;
/// Transparently provide more efficient getOperand methods.
@@ -577,7 +577,7 @@ public:
Op<1>() = Val;
}
- /// Indicies - These identify the position for the insertion.
+ /// Indices - These identify the position for the insertion.
const SmallVector<unsigned, 4> Indices;
/// Transparently provide more efficient getOperand methods.
@@ -2339,7 +2339,7 @@ Constant *ConstantExpr::getExtractValueTy(const Type *ReqTy, Constant *Agg,
// Look up the constant in the table first to ensure uniqueness
std::vector<Constant*> ArgVec;
ArgVec.push_back(Agg);
- SmallVector<unsigned, 4> Indices;
+ SmallVector<unsigned, 4> Indices(Idxs, Idxs + NumIdx);
const ExprMapKeyType Key(Instruction::ExtractValue, ArgVec, 0, Indices);
return ExprConstants->getOrCreate(ReqTy, Key);
}
OpenPOWER on IntegriCloud