summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorDan Gohman <gohman@apple.com>2009-01-06 22:53:52 +0000
committerDan Gohman <gohman@apple.com>2009-01-06 22:53:52 +0000
commit2c91d102ec29bc766b7172a3062d399dc12640fe (patch)
treeb98481838c8f6a38f1ac8ba0227b2965333a8281 /lib
parent5d315989542ffe720d9a835010bd7be957e6a830 (diff)
downloadllvm-2c91d102ec29bc766b7172a3062d399dc12640fe.tar.gz
llvm-2c91d102ec29bc766b7172a3062d399dc12640fe.tar.bz2
llvm-2c91d102ec29bc766b7172a3062d399dc12640fe.tar.xz
Fix a bug in ComputeLinearIndex computation handling multi-level
aggregate types. Don't increment the current index after reaching the end of a struct, as it will already be pointing at one-past-the end. This fixes PR3288. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@61828 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib')
-rw-r--r--lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
index 4f17164ce6..c8985b47f0 100644
--- a/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
+++ b/lib/CodeGen/SelectionDAG/SelectionDAGBuild.cpp
@@ -63,7 +63,7 @@ LimitFPPrecision("limit-float-precision",
cl::init(0));
/// ComputeLinearIndex - Given an LLVM IR aggregate type and a sequence
-/// insertvalue or extractvalue indices that identify a member, return
+/// of insertvalue or extractvalue indices that identify a member, return
/// the linearized index of the start of the member.
///
static unsigned ComputeLinearIndex(const TargetLowering &TLI, const Type *Ty,
@@ -84,6 +84,7 @@ static unsigned ComputeLinearIndex(const TargetLowering &TLI, const Type *Ty,
return ComputeLinearIndex(TLI, *EI, Indices+1, IndicesEnd, CurIndex);
CurIndex = ComputeLinearIndex(TLI, *EI, 0, 0, CurIndex);
}
+ return CurIndex;
}
// Given an array type, recursively traverse the elements.
else if (const ArrayType *ATy = dyn_cast<ArrayType>(Ty)) {
@@ -93,6 +94,7 @@ static unsigned ComputeLinearIndex(const TargetLowering &TLI, const Type *Ty,
return ComputeLinearIndex(TLI, EltTy, Indices+1, IndicesEnd, CurIndex);
CurIndex = ComputeLinearIndex(TLI, EltTy, 0, 0, CurIndex);
}
+ return CurIndex;
}
// We haven't found the type we're looking for, so keep searching.
return CurIndex + 1;