[Llvm-bgq-discuss] Implicit memset call
Thomas Gooding
tgooding at us.ibm.com
Thu Mar 20 11:06:53 CDT 2014
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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.alcf.anl.gov/pipermail/llvm-bgq-discuss/attachments/20140320/6952d4da/attachment.html>
More information about the llvm-bgq-discuss
mailing list