From 996d7a97f94de45a3627b03eb3c44b2b325f3e51 Mon Sep 17 00:00:00 2001 From: Chris Lattner Date: Mon, 2 Feb 2009 18:02:59 +0000 Subject: Fix a bug which caused us to miscompile a couple of Ada tests. Thanks for the beautiful reduced testcase Duncan! git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@63529 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/ScalarReplAggregates.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'lib/Transforms') diff --git a/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/lib/Transforms/Scalar/ScalarReplAggregates.cpp index 29970ecb44..0765e12876 100644 --- a/lib/Transforms/Scalar/ScalarReplAggregates.cpp +++ b/lib/Transforms/Scalar/ScalarReplAggregates.cpp @@ -1166,12 +1166,17 @@ void SROA::CanonicalizeAllocaUsers(AllocationInst *AI) { static void MergeInType(const Type *In, uint64_t Offset, const Type *&Accum, const TargetData &TD) { // If this is our first type, just use it. - if (Accum == 0 || In == Type::VoidTy || + if ((Accum == 0 && Offset == 0) || In == Type::VoidTy || // Or if this is a same type, keep it. (In == Accum && Offset == 0)) { Accum = In; return; } + + // Merging something like i32 into offset 8 means that a "field" is merged in + // before the basic type is. Make sure to consider the offset below. + if (Accum == 0) + Accum = Type::Int8Ty; if (const VectorType *VATy = dyn_cast(Accum)) { if (VATy->getElementType() == In && -- cgit v1.2.3-70-g09d2