<html><body>
<p><font size="2" face="sans-serif">Hi Hal,</font><br>
<br>
<font size="2" face="sans-serif">The -fno-builtin-memset option does not seem to work for me.</font><br>
<font size="2" face="Menlo-Regular"> Building with "bgclang -g -fno-builtin-memset -O2 t.c" still shows the branch-link to memset.</font><br>
<br>
<br>
<font size="2" face="sans-serif">However, -fno-builtin did the trick. </font><br>
<br>
<font size="2" face="sans-serif">Tom</font><br>
<br>
<font size="2" face="sans-serif">Tom Gooding<br>
Senior Engineer / Blue Gene SW Lead / CAPI<br>
tgooding@us.ibm.com 507-253-0747<br>
</font><br>
<br>
<img width="16" height="16" src="cid:1__=08BBF632DFFC17A58f9e8a93df938@us.ibm.com" border="0" alt="Inactive hide details for Hal Finkel ---03/20/2014 11:43:55 AM---Tom, Jeff, I recommend using -fno-builtin-memset in this case "><font size="2" color="#424282" face="sans-serif">Hal Finkel ---03/20/2014 11:43:55 AM---Tom, Jeff, I recommend using -fno-builtin-memset in this case (and, generally, -fno-builtin-<foo> ca</font><br>
<br>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:2__=08BBF632DFFC17A58f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<ul style="padding-left: 4pt"><font size="1" color="#5F5F5F" face="sans-serif">From:</font></ul>
</td><td width="100%"><img width="1" height="1" src="cid:2__=08BBF632DFFC17A58f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<font size="1" face="sans-serif">Hal Finkel <hfinkel@anl.gov></font></td></tr>
<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:2__=08BBF632DFFC17A58f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<ul style="padding-left: 4pt"><font size="1" color="#5F5F5F" face="sans-serif">To:</font></ul>
</td><td width="100%"><img width="1" height="1" src="cid:2__=08BBF632DFFC17A58f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<font size="1" face="sans-serif">Jeff Hammond <jhammond@anl.gov></font></td></tr>
<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:2__=08BBF632DFFC17A58f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<ul style="padding-left: 4pt"><font size="1" color="#5F5F5F" face="sans-serif">Cc:</font></ul>
</td><td width="100%" valign="middle"><img width="1" height="1" src="cid:2__=08BBF632DFFC17A58f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<font size="1" face="sans-serif">llvm-bgq-discuss@lists.alcf.anl.gov</font></td></tr>
<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:2__=08BBF632DFFC17A58f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<ul style="padding-left: 4pt"><font size="1" color="#5F5F5F" face="sans-serif">Date:</font></ul>
</td><td width="100%"><img width="1" height="1" src="cid:2__=08BBF632DFFC17A58f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<font size="1" face="sans-serif">03/20/2014 11:43 AM</font></td></tr>
<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:2__=08BBF632DFFC17A58f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<ul style="padding-left: 4pt"><font size="1" color="#5F5F5F" face="sans-serif">Subject:</font></ul>
</td><td width="100%"><img width="1" height="1" src="cid:2__=08BBF632DFFC17A58f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<font size="1" face="sans-serif">Re: [Llvm-bgq-discuss] Implicit memset call</font></td></tr>
<tr valign="top"><td width="1%"><img width="96" height="1" src="cid:2__=08BBF632DFFC17A58f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<ul style="padding-left: 4pt"><font size="1" color="#5F5F5F" face="sans-serif">Sent by:</font></ul>
</td><td width="100%"><img width="1" height="1" src="cid:2__=08BBF632DFFC17A58f9e8a93df938@us.ibm.com" border="0" alt=""><br>
<font size="1" face="sans-serif">llvm-bgq-discuss-bounces@lists.alcf.anl.gov</font></td></tr>
</table>
<hr width="100%" size="2" align="left" noshade style="color:#8091A5; "><br>
<br>
<br>
<tt><font size="2">Tom, Jeff,<br>
<br>
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.<br>
<br>
-Hal<br>
<br>
----- Original Message -----<br>
> From: "Jeff Hammond" <jhammond@anl.gov><br>
> To: "Jeff Hammond" <jhammond@anl.gov><br>
> Cc: llvm-bgq-discuss@lists.alcf.anl.gov<br>
> Sent: Thursday, March 20, 2014 11:22:03 AM<br>
> Subject: Re: [Llvm-bgq-discuss] Implicit memset call<br>
> <br>
> Per </font></tt><tt><font size="2"><a href="http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-May/050112.html">http://lists.cs.uiuc.edu/pipermail/llvmdev/2012-May/050112.html</a></font></tt><tt><font size="2">,<br>
> you might want to try -fno-builtin and/or -ffreestanding.<br>
> <br>
> Jeff<br>
> <br>
> On Thu, Mar 20, 2014 at 11:17 AM, Jeff Hammond <jhammond@anl.gov><br>
> wrote:<br>
> > As best I can tell, this bug is upstream as well. I see the same<br>
> > thing happen on my Mac with Clang 3.4.<br>
> ><br>
> > Jeff<br>
> ><br>
> > On Thu, Mar 20, 2014 at 11:06 AM, Thomas Gooding<br>
> > <tgooding@us.ibm.com> wrote:<br>
> >> Hello,<br>
> >><br>
> >> I have some code that implements the memset() routine. It appears<br>
> >> that<br>
> >> bgclang is getting (too) clever by detecting the setting-loop.<br>
> >> Once it<br>
> >> detects this, it decides the "real" memset would be more efficient<br>
> >> and calls<br>
> >> that routine inplace of the setting-loop. Very clever, but not<br>
> >> optimal for<br>
> >> me (and functionally incorrect since in the real code, it results<br>
> >> in a<br>
> >> recursive bomb calling memset repeatedly)<br>
> >><br>
> >> Is there a way to disable this feature?<br>
> >><br>
> >> bgclang -g -O2 t.c<br>
> >><br>
> >> #include <stdio.h><br>
> >> #include <stdint.h><br>
> >><br>
> >> char buffer[24];<br>
> >><br>
> >> void* my_memset(void* dest, int value, size_t n )<br>
> >> {<br>
> >> printf("memset: dest=%p size=%ld\n", dest, n);<br>
> >> uint8_t* d = (uint8_t*)dest;<br>
> >> while (n--)<br>
> >> *d++ = value; // this while loop<br>
> >> replaced with<br>
> >> memset() call<br>
> >> return dest;<br>
> >> }<br>
> >><br>
> >> int main(int argc, char** argv)<br>
> >> {<br>
> >> my_memset(buffer, 0, sizeof(buffer));<br>
> >> printf("done\n");<br>
> >> return 0;<br>
> >> }<br>
> >><br>
> >> 00000000010003c0 <.my_memset>:<br>
> >> 10003c0: 7c 08 02 a6 mflr r0<br>
> >> 10003c4: fb e1 ff f8 std r31,-8(r1)<br>
> >> 10003c8: f8 01 00 10 std r0,16(r1)<br>
> >> 10003cc: f8 21 ff 61 stdu r1,-160(r1)<br>
> >> ....<br>
> >> 1000408: 7b 84 06 20 clrldi r4,r28,56<br>
> >> 100040c: 7f c3 f3 78 mr r3,r30<br>
> >> 1000410: 7f a5 eb 78 mr r5,r29<br>
> >> 1000414: 48 00 d0 7d bl 100d490 <.memset><br>
> >><br>
> >> Tom Gooding<br>
> >> Senior Engineer / Blue Gene SW Lead / CAPI<br>
> >> tgooding@us.ibm.com 507-253-0747<br>
> >><br>
> >><br>
> >> _______________________________________________<br>
> >> llvm-bgq-discuss mailing list<br>
> >> llvm-bgq-discuss@lists.alcf.anl.gov<br>
> >> </font></tt><tt><font size="2"><a href="https://lists.alcf.anl.gov/mailman/listinfo/llvm-bgq-discuss">https://lists.alcf.anl.gov/mailman/listinfo/llvm-bgq-discuss</a></font></tt><tt><font size="2"><br>
> >><br>
> ><br>
> ><br>
> ><br>
> > --<br>
> > Jeff Hammond<br>
> > Argonne Leadership Computing Facility<br>
> > University of Chicago Computation Institute<br>
> > jhammond@anl.gov / jhammond@uchicago.edu / (630) 252-5381<br>
> > </font></tt><tt><font size="2"><a href="http://www.linkedin.com/in/jeffhammond">http://www.linkedin.com/in/jeffhammond</a></font></tt><tt><font size="2"><br>
> > </font></tt><tt><font size="2"><a href="https://wiki.alcf.anl.gov/parts/index.php/User:Jhammond">https://wiki.alcf.anl.gov/parts/index.php/User:Jhammond</a></font></tt><tt><font size="2"><br>
> <br>
> <br>
> <br>
> --<br>
> Jeff Hammond<br>
> Argonne Leadership Computing Facility<br>
> University of Chicago Computation Institute<br>
> jhammond@anl.gov / jhammond@uchicago.edu / (630) 252-5381<br>
> </font></tt><tt><font size="2"><a href="http://www.linkedin.com/in/jeffhammond">http://www.linkedin.com/in/jeffhammond</a></font></tt><tt><font size="2"><br>
> </font></tt><tt><font size="2"><a href="https://wiki.alcf.anl.gov/parts/index.php/User:Jhammond">https://wiki.alcf.anl.gov/parts/index.php/User:Jhammond</a></font></tt><tt><font size="2"><br>
> _______________________________________________<br>
> llvm-bgq-discuss mailing list<br>
> llvm-bgq-discuss@lists.alcf.anl.gov<br>
> </font></tt><tt><font size="2"><a href="https://lists.alcf.anl.gov/mailman/listinfo/llvm-bgq-discuss">https://lists.alcf.anl.gov/mailman/listinfo/llvm-bgq-discuss</a></font></tt><tt><font size="2"><br>
> <br>
<br>
-- <br>
Hal Finkel<br>
Assistant Computational Scientist<br>
Leadership Computing Facility<br>
Argonne National Laboratory<br>
_______________________________________________<br>
llvm-bgq-discuss mailing list<br>
llvm-bgq-discuss@lists.alcf.anl.gov<br>
</font></tt><tt><font size="2"><a href="https://lists.alcf.anl.gov/mailman/listinfo/llvm-bgq-discuss">https://lists.alcf.anl.gov/mailman/listinfo/llvm-bgq-discuss</a></font></tt><tt><font size="2"><br>
<br>
</font></tt><br>
<br>
</body></html>