[Llvm-bgq-discuss] Implicit memset call
Thomas Gooding
tgooding at us.ibm.com
Thu Mar 20 15:22:20 CDT 2014
Hi Hal,
The -fno-builtin-memset option does not seem to work for me.
Building with "bgclang -g -fno-builtin-memset -O2 t.c" still shows
the branch-link to memset.
However, -fno-builtin did the trick.
Tom
Tom Gooding
Senior Engineer / Blue Gene SW Lead / CAPI
tgooding at us.ibm.com 507-253-0747
|------------>
| From: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|Hal Finkel <hfinkel at anl.gov> |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| To: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|Jeff Hammond <jhammond at anl.gov> |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Cc: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|llvm-bgq-discuss at lists.alcf.anl.gov |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Date: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|03/20/2014 11:43 AM |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Subject: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|Re: [Llvm-bgq-discuss] Implicit memset call |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|------------>
| Sent by: |
|------------>
>--------------------------------------------------------------------------------------------------------------------------------------------------|
|llvm-bgq-discuss-bounces at lists.alcf.anl.gov |
>--------------------------------------------------------------------------------------------------------------------------------------------------|
Tom, Jeff,
I recommend using -fno-builtin-memset in this case (and, generally,
-fno-builtin-<foo> can be used for any foo that you've replaced that it
part of the standard library). If you just use -fno-builtin generally
you'll miss out on a bunch of useful optimizations. In fact, since you have
a good memset that you'd actually like to use, I recommend putting it into
its own file and compiling only that file with -fno-builtin-memset.
-Hal
----- Original Message -----
> From: "Jeff Hammond" <jhammond at anl.gov>
> To: "Jeff Hammond" <jhammond at anl.gov>
> Cc: llvm-bgq-discuss at lists.alcf.anl.gov
> Sent: Thursday, March 20, 2014 11:22:03 AM
> Subject: Re: [Llvm-bgq-discuss] Implicit memset call
>
> Per http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-May/050112.html,
> you might want to try -fno-builtin and/or -ffreestanding.
>
> Jeff
>
> On Thu, Mar 20, 2014 at 11:17 AM, Jeff Hammond <jhammond at anl.gov>
> wrote:
> > As best I can tell, this bug is upstream as well. I see the same
> > thing happen on my Mac with Clang 3.4.
> >
> > Jeff
> >
> > On Thu, Mar 20, 2014 at 11:06 AM, Thomas Gooding
> > <tgooding at us.ibm.com> wrote:
> >> Hello,
> >>
> >> I have some code that implements the memset() routine. It appears
> >> that
> >> bgclang is getting (too) clever by detecting the setting-loop.
> >> Once it
> >> detects this, it decides the "real" memset would be more efficient
> >> and calls
> >> that routine inplace of the setting-loop. Very clever, but not
> >> optimal for
> >> me (and functionally incorrect since in the real code, it results
> >> in a
> >> recursive bomb calling memset repeatedly)
> >>
> >> Is there a way to disable this feature?
> >>
> >> bgclang -g -O2 t.c
> >>
> >> #include <stdio.h>
> >> #include <stdint.h>
> >>
> >> char buffer[24];
> >>
> >> void* my_memset(void* dest, int value, size_t n )
> >> {
> >> printf("memset: dest=%p size=%ld\n", dest, n);
> >> uint8_t* d = (uint8_t*)dest;
> >> while (n--)
> >> *d++ = value; // this while loop
> >> replaced with
> >> memset() call
> >> return dest;
> >> }
> >>
> >> int main(int argc, char** argv)
> >> {
> >> my_memset(buffer, 0, sizeof(buffer));
> >> printf("done\n");
> >> return 0;
> >> }
> >>
> >> 00000000010003c0 <.my_memset>:
> >> 10003c0: 7c 08 02 a6 mflr r0
> >> 10003c4: fb e1 ff f8 std r31,-8(r1)
> >> 10003c8: f8 01 00 10 std r0,16(r1)
> >> 10003cc: f8 21 ff 61 stdu r1,-160(r1)
> >> ....
> >> 1000408: 7b 84 06 20 clrldi r4,r28,56
> >> 100040c: 7f c3 f3 78 mr r3,r30
> >> 1000410: 7f a5 eb 78 mr r5,r29
> >> 1000414: 48 00 d0 7d bl 100d490 <.memset>
> >>
> >> Tom Gooding
> >> Senior Engineer / Blue Gene SW Lead / CAPI
> >> tgooding at us.ibm.com 507-253-0747
> >>
> >>
> >> _______________________________________________
> >> llvm-bgq-discuss mailing list
> >> llvm-bgq-discuss at lists.alcf.anl.gov
> >> https://lists.alcf.anl.gov/mailman/listinfo/llvm-bgq-discuss
> >>
> >
> >
> >
> > --
> > Jeff Hammond
> > Argonne Leadership Computing Facility
> > University of Chicago Computation Institute
> > jhammond at anl.gov / jhammond at uchicago.edu / (630) 252-5381
> > http://www.linkedin.com/in/jeffhammond
> > https://wiki.alcf.anl.gov/parts/index.php/User:Jhammond
>
>
>
> --
> Jeff Hammond
> Argonne Leadership Computing Facility
> University of Chicago Computation Institute
> jhammond at anl.gov / jhammond at uchicago.edu / (630) 252-5381
> http://www.linkedin.com/in/jeffhammond
> https://wiki.alcf.anl.gov/parts/index.php/User:Jhammond
> _______________________________________________
> llvm-bgq-discuss mailing list
> llvm-bgq-discuss at lists.alcf.anl.gov
> https://lists.alcf.anl.gov/mailman/listinfo/llvm-bgq-discuss
>
--
Hal Finkel
Assistant Computational Scientist
Leadership Computing Facility
Argonne National Laboratory
_______________________________________________
llvm-bgq-discuss mailing list
llvm-bgq-discuss at lists.alcf.anl.gov
https://lists.alcf.anl.gov/mailman/listinfo/llvm-bgq-discuss
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alcf.anl.gov/pipermail/llvm-bgq-discuss/attachments/20140320/574c9ada/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: graycol.gif
Type: image/gif
Size: 105 bytes
Desc: not available
URL: <http://lists.alcf.anl.gov/pipermail/llvm-bgq-discuss/attachments/20140320/574c9ada/attachment.gif>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: ecblank.gif
Type: image/gif
Size: 45 bytes
Desc: not available
URL: <http://lists.alcf.anl.gov/pipermail/llvm-bgq-discuss/attachments/20140320/574c9ada/attachment-0001.gif>
More information about the llvm-bgq-discuss
mailing list