diff options
Diffstat (limited to 'lib/IR/ConstantFold.cpp')
| -rw-r--r-- | lib/IR/ConstantFold.cpp | 6 | 
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/IR/ConstantFold.cpp b/lib/IR/ConstantFold.cpp index 3f64c43e902d..2efc61242eac 100644 --- a/lib/IR/ConstantFold.cpp +++ b/lib/IR/ConstantFold.cpp @@ -2165,9 +2165,9 @@ static Constant *ConstantFoldGetElementPtrImpl(Type *PointeeTy, Constant *C,    // factored out into preceding dimensions.    bool Unknown = false;    SmallVector<Constant *, 8> NewIdxs; -  Type *Ty = PointeeTy; -  Type *Prev = C->getType(); -  for (unsigned i = 1, e = Idxs.size(); i != e; +  Type *Ty = C->getType(); +  Type *Prev = nullptr; +  for (unsigned i = 0, e = Idxs.size(); i != e;         Prev = Ty, Ty = cast<CompositeType>(Ty)->getTypeAtIndex(Idxs[i]), ++i) {      if (ConstantInt *CI = dyn_cast<ConstantInt>(Idxs[i])) {        if (isa<ArrayType>(Ty) || isa<VectorType>(Ty))  | 
