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

Eli Friedman eli.friedman at gmail.com
Tue Sep 25 18:10:01 PDT 2012


On Tue, Sep 25, 2012 at 3:46 PM, Nick Lewycky <nicholas at mxc.ca> wrote:
> Author: nicholas
> Date: Tue Sep 25 17:46:21 2012
> New Revision: 164641
>
> URL: http://llvm.org/viewvc/llvm-project?rev=164641&view=rev
> Log:
> Don't drop the alignment on a memcpy intrinsic when producing a store. This is
> only a missed optimization opportunity if the store is over-aligned, but a
> miscompile if the store's new type has a higher natural alignment than the
> memcpy did. Fixes PR13920!
>
> 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=164641&r1=164640&r2=164641&view=diff
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/SROA.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/SROA.cpp Tue Sep 25 17:46:21 2012
> @@ -2272,8 +2272,9 @@
>                                      getName(".insert"));
>      }
>
> -    Value *Store = IRB.CreateStore(Src, DstPtr, II.isVolatile());
> -    (void)Store;
> +    StoreInst *Store = cast<StoreInst>(IRB.CreateStore(Src, DstPtr,
> +                                                       II.isVolatile()));
> +    Store->setAlignment(II.getAlignment());

This isn't quite right: "0" alignment on a store has a different
meaning from "0" alignment on a memcpy.

-Eli



More information about the llvm-commits mailing list