From: Bill Wendling Date: Mon, 4 Aug 2014 04:28:45 +0000 (+0000) Subject: Merging r213726: X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=92a10767eba0b31e156265d3e149f464379f75aa;p=llvm Merging r213726: ------------------------------------------------------------------------ r213726 | nicholas | 2014-07-22 23:24:49 -0700 (Tue, 22 Jul 2014) | 2 lines We may visit a call that uses an alloca multiple times in callUsesLocalStack, sometimes with IsNocapture true and sometimes with IsNocapture false. We accidentally skipped work we needed to do in the IsNocapture=false case if we were called with IsNocapture=true the first time. Fixes PR20405! ------------------------------------------------------------------------ git-svn-id: https://llvm.org/svn/llvm-project/llvm/branches/release_35@214688 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/Transforms/Scalar/TailRecursionElimination.cpp b/lib/Transforms/Scalar/TailRecursionElimination.cpp index 05b9892470b..b7580255150 100644 --- a/lib/Transforms/Scalar/TailRecursionElimination.cpp +++ b/lib/Transforms/Scalar/TailRecursionElimination.cpp @@ -227,12 +227,10 @@ struct AllocaDerivedValueTracker { } void callUsesLocalStack(CallSite CS, bool IsNocapture) { - // Add it to the list of alloca users. If it's already there, skip further - // processing. - if (!AllocaUsers.insert(CS.getInstruction())) - return; + // Add it to the list of alloca users. + AllocaUsers.insert(CS.getInstruction()); - // If it's nocapture then it can't capture the alloca. + // If it's nocapture then it can't capture this alloca. if (IsNocapture) return; diff --git a/test/Transforms/TailCallElim/basic.ll b/test/Transforms/TailCallElim/basic.ll index 341736d48ef..8e9814b52bb 100644 --- a/test/Transforms/TailCallElim/basic.ll +++ b/test/Transforms/TailCallElim/basic.ll @@ -174,3 +174,17 @@ if.end: return: ret void } + +declare void @test11_helper1(i8** nocapture, i8*) +declare void @test11_helper2(i8*) +define void @test11() { +; CHECK-LABEL: @test11 +; CHECK-NOT: tail + %a = alloca i8* + %b = alloca i8 + call void @test11_helper1(i8** %a, i8* %b) ; a = &b + %c = load i8** %a + call void @test11_helper2(i8* %c) +; CHECK: call void @test11_helper2 + ret void +}