From 851ff69b42e690cd8e7500218e1b7107749035c5 Mon Sep 17 00:00:00 2001 From: Tim Northover Date: Mon, 4 May 2015 20:41:51 +0000 Subject: CodeGen: match up correct insertvalue indices when assessing tail calls. When deciding whether a value comes from the aggregate or inserted value of an insertvalue instruction, we compare the indices against those of the location we're interested in. One of the lists needs reversing because the input data is backwards (so that modifications take place at the end of the SmallVector), but we were reversing both before leading to incorrect results. Should fix PR23408 llvm-svn: 236457 --- llvm/lib/CodeGen/Analysis.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'llvm/lib/CodeGen/Analysis.cpp') diff --git a/llvm/lib/CodeGen/Analysis.cpp b/llvm/lib/CodeGen/Analysis.cpp index 8e11fe1c9cf..ac0d40ec3a7 100644 --- a/llvm/lib/CodeGen/Analysis.cpp +++ b/llvm/lib/CodeGen/Analysis.cpp @@ -295,7 +295,8 @@ static const Value *getNoopInput(const Value *V, } else if (const InsertValueInst *IVI = dyn_cast(V)) { // Value may come from either the aggregate or the scalar ArrayRef InsertLoc = IVI->getIndices(); - if (std::equal(InsertLoc.rbegin(), InsertLoc.rend(), + assert(ValLoc.size() >= InsertLoc.size() && "extracting too deeply"); + if (std::equal(InsertLoc.begin(), InsertLoc.end(), ValLoc.rbegin())) { // The type being inserted is a nested sub-type of the aggregate; we // have to remove those initial indices to get the location we're -- cgit v1.2.3