[PATCH] Optimize double storing by memset; memcpy

Joel Jones joel_k_jones at apple.com
Mon Mar 4 00:02:46 PST 2013


We have tests that are structured like that, and a good percentage of the ones related to library calls fail when written as end-to-end tests.  A single change in the chain of name changes and macros and the tests no longer connect with reality.  I'll give some specific examples in the morning.  The optimization isn't the only important piece here.  It is also that the library calls as a user would write them are actually exposed to optimization.

Joel


On Mar 3, 2013, at 11:31 PM, Chandler Carruth <chandlerc at google.com> wrote:

> On Sun, Mar 3, 2013 at 11:24 PM, Joel Jones <joel_k_jones at apple.com> wrote:
>   This is the C source from the clang repo.
> 
> Clang shouldn't be providing tests for LLVM's optimizers ever really. While we have some, the number should really decrease. (There are a very few exceptions, but this certainly doesn't seem like one...)
> 
> Instead, if you want to test this, check that clang (without any optimizations) emits the particular IR patterns of interest. Then provide LLVM-based IR->IR tests which isolate the simplifications you expect to happen here entirely within the LLVM pipeline.
>  
> 
> http://llvm-reviews.chandlerc.com/D489
> 
> CHANGE SINCE LAST DIFF
>   http://llvm-reviews.chandlerc.com/D489?vs=1179&id=1180#toc
> 
> Files:
>   test/CodeGen/memSetCpy.c
> 
> Index: test/CodeGen/memSetCpy.c
> ===================================================================
> --- test/CodeGen/memSetCpy.c
> +++ test/CodeGen/memSetCpy.c
> @@ -0,0 +1,16 @@
> +// RUN: %clang -O3 -S -emit-llvm  %s -o - | FileCheck %s
> +// Note: using clang here as it is very easy to end up with C source that
> +// doesn't actually produce llvm.mem* intrinsics that the memset; memcpy
> +// argument rewriting depends upon.  This test may be too fragile in the form
> +// here.  Another LLVM IR only source file tests the transformation as well,
> +// and is less dependent upon host compilation environments.
> +
> +#include <strings.h>
> +
> +void foo(char* src, int src_size, char* dest, int dest_size)
> +{
> +// CHECK: call void @llvm.memcpy.p0i8.p0i8.i64(i8* %dest, i8* %src,
> +// CHECK: call void @llvm.memset.p0i8.i64(i8*
> +  memset(dest, 0, dest_size);
> +  memcpy(dest, src, src_size);
> +}
> 
> _______________________________________________
> 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/20130304/c8a7d76a/attachment.html>


More information about the llvm-commits mailing list