[llvm-commits] [llvm] r164634 - in /llvm/trunk: lib/Transforms/Scalar/SROA.cpp test/Transforms/SROA/basictest.ll

Nick Lewycky nlewycky at google.com
Tue Sep 25 14:35:44 PDT 2012


On 25 September 2012 14:15, Nick Lewycky <nicholas at mxc.ca> wrote:

> Author: nicholas
> Date: Tue Sep 25 16:15:50 2012
> New Revision: 164634
>
> URL: http://llvm.org/viewvc/llvm-project?rev=164634&view=rev
> Log:
> Don't try to promote the same alloca twice. Fixes PR13916!
>
> Chandler, it's not obvious that it's okay that this alloca gets into the
> list
> twice to begin with. Please review and see whether this is the fix you
> really
> want, but I wanted to get a fix checked in quickly.
>
> Modified:
>     llvm/trunk/lib/Transforms/Scalar/SROA.cpp
>     llvm/trunk/test/Transforms/SROA/basictest.ll
>
> Modified: llvm/trunk/lib/Transforms/Scalar/SROA.cpp
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/SROA.cpp?rev=164634&r1=164633&r2=164634&view=diff
>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/SROA.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/SROA.cpp Tue Sep 25 16:15:50 2012
> @@ -3108,6 +3108,12 @@
>    if (PromotableAllocas.empty())
>      return false;
>
> +  // Ensure that the list is unique.
> +  std::sort(PromotableAllocas.begin(), PromotableAllocas.end());
> +  PromotableAllocas.erase(std::unique(PromotableAllocas.begin(),
> +                                      PromotableAllocas.end()),
> +                          PromotableAllocas.end());
>

In self-review, I note that sorting the list of AllocaInst* causes us to
have an undefined order of creating PHI node instructions.

I'm already working on a fix. Sorry for the trouble.

Nick


> +
>    NumPromoted += PromotableAllocas.size();
>
>    if (DT && !ForceSSAUpdater) {
>
> Modified: llvm/trunk/test/Transforms/SROA/basictest.ll
> URL:
> http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/SROA/basictest.ll?rev=164634&r1=164633&r2=164634&view=diff
>
> ==============================================================================
> --- llvm/trunk/test/Transforms/SROA/basictest.ll (original)
> +++ llvm/trunk/test/Transforms/SROA/basictest.ll Tue Sep 25 16:15:50 2012
> @@ -855,3 +855,25 @@
>    %result = or i8 %load, %load2
>    ret i8 %result
>  }
> +
> +%test22.struct = type { i8 }
> +
> +define void @test22() {
> +; CHECK: @test22
> +; CHECK-NOT: alloca
> +; CHECK: ret void
> +; PR13916
> +entry:
> +  %A = alloca %test22.struct
> +  br i1 undef, label %if.then, label %if.end
> +
> +if.then:                                          ; preds = %entry
> +  %tmp = bitcast %test22.struct* %A to i8*
> +  %tmp1 = bitcast %test22.struct* %A to i8*
> +  call void @llvm.memcpy.p0i8.p0i8.i32(i8* %tmp, i8* %tmp1, i32 1, i32 1,
> i1 false)
> +  unreachable
> +
> +if.end:                                           ; preds = %entry
> +  %tmp2 = load %test22.struct* %A
> +  ret void
> +}
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20120925/3c1c3a7b/attachment.html>


More information about the llvm-commits mailing list