[Llvm-bgq-discuss] Implicit memset call
Jeff Hammond
jhammond at anl.gov
Thu Mar 20 11:17:35 CDT 2014
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
More information about the llvm-bgq-discuss
mailing list