Hi,<div><br></div><div>I have the following program:</div><div><br></div><div><font face="courier new, monospace">// test.c</font></div><div><div><font face="courier new, monospace">#include <stdlib.h></font></div><div>
<font face="courier new, monospace">struct foo_t {</font></div><div><font face="courier new, monospace"> int x[1024];</font></div><div><font face="courier new, monospace">};</font></div><div><font face="courier new, monospace">__thread struct foo_t g_foo;</font></div>
<div><font face="courier new, monospace">void bar(struct foo_t* foo) {</font></div><div><font face="courier new, monospace"> g_foo = *foo;</font></div><div><font face="courier new, monospace">}</font></div><div><font face="courier new, monospace">int main() {</font></div>
<div><font face="courier new, monospace"> struct foo_t* f = (struct foo_t*)malloc(sizeof(struct foo_t));</font></div><div><font face="courier new, monospace"> bar(f);</font></div><div><font face="courier new, monospace"> return 0;</font></div>
<div><font face="courier new, monospace">}</font></div></div><div><br></div><div>When I compile it with clang I see that it inserts memcpy() in function bar():</div><div><br></div><div><div>$ clang -v</div><div>clang version 3.2 (trunk 157390)</div>
<div>Target: x86_64-unknown-linux-gnu</div><div>Thread model: posix</div><div>$ clang test.c -g && objdump -dCS a.out</div></div><div><br></div><div><div><font face="courier new, monospace">void bar(struct foo_t* foo) {</font></div>
<div><font face="courier new, monospace"> 4005b0: 55 push %rbp</font></div><div><font face="courier new, monospace"> 4005b1: 48 89 e5 mov %rsp,%rbp</font></div><div><font face="courier new, monospace"> 4005b4: 48 83 ec 10 sub $0x10,%rsp</font></div>
<div><font face="courier new, monospace"> 4005b8: 48 89 7d f8 mov %rdi,-0x8(%rbp)</font></div><div><font face="courier new, monospace"> g_foo = *foo;</font></div><div><font face="courier new, monospace"> 4005bc: 48 8b 7d f8 mov -0x8(%rbp),%rdi</font></div>
<div><font face="courier new, monospace"> 4005c0: 64 48 8b 04 25 00 00 mov %fs:0x0,%rax</font></div><div><font face="courier new, monospace"> 4005c7: 00 00 </font></div><div><font face="courier new, monospace"> 4005c9: 48 8d 80 00 f0 ff ff lea -0x1000(%rax),%rax</font></div>
<div><font face="courier new, monospace"> 4005d0: ba 00 10 00 00 mov $0x1000,%edx</font></div><div><font face="courier new, monospace"> 4005d5: 48 89 7d f0 mov %rdi,-0x10(%rbp)</font></div>
<div><font face="courier new, monospace"> 4005d9: 48 89 c7 mov %rax,%rdi</font></div><div><font face="courier new, monospace"> 4005dc: 48 8b 75 f0 mov -0x10(%rbp),%rsi</font></div>
<div><font face="courier new, monospace"> 4005e0: e8 c3 fe ff ff <b>callq 4004a8 <memcpy@plt></b></font></div><div><font face="courier new, monospace">}</font></div><div><font face="courier new, monospace"> 4005e5: 48 83 c4 10 add $0x10,%rsp</font></div>
<div><font face="courier new, monospace"> 4005e9: 5d pop %rbp</font></div><div><font face="courier new, monospace"> 4005ea: c3 retq </font></div><div><font face="courier new, monospace"> 4005eb: 0f 1f 44 00 00 nopl 0x0(%rax,%rax,1)</font></div>
</div><div><br></div><div>How do I disable that feature? I've tried -fno-builtin and/or -ffreestanding with no success.</div><div>TIA</div>