[cfe-dev] compiler difference between mac clang and linux clang
Doug Snyder
dsnyder at blueshiftinc.com
Mon Jul 21 16:50:02 PDT 2014
while debugging lldb unit test “functionalities/step-avoids-no-debug”, i noticed that the mac version of clang associated a different set of machine code to a source line than the linux version of clang, even though the machine code generated by the two version was almost identical. This difference was noticed when i was looking at the Range values passed to “Thread::QueueThreadPlanForSteoOverRange()” in lldb.
the source line in question is line 12 of “with-debug.c” in the unit test directory
mac clang associates source line 12 (return return_value;) with (9) machine code bytes starting at address 100000e59 (shown below)
0000000100000e30 <_called_from_nodebug_actual>:
100000e30: 55 push %rbp
100000e31: 48 89 e5 mov %rsp,%rbp
100000e34: 48 83 ec 10 sub $0x10,%rsp
100000e38: 48 8d 05 2f 01 00 00 lea 0x12f(%rip),%rax # 100000f6e <_printf$stub+0x20>
100000e3f: 89 7d fc mov %edi,-0x4(%rbp)
100000e42: c7 45 f8 00 00 00 00 movl $0x0,-0x8(%rbp)
100000e49: 8b 75 fc mov -0x4(%rbp),%esi
100000e4c: 48 89 c7 mov %rax,%rdi
100000e4f: b0 00 mov $0x0,%al
100000e51: e8 f8 00 00 00 callq 100000f4e <_printf$stub>
100000e56: 89 45 f8 mov %eax,-0x8(%rbp)
100000e59: 8b 45 f8 mov -0x8(%rbp),%eax
100000e5c: 48 83 c4 10 add $0x10,%rsp
100000e60: 5d pop %rbp
100000e61: c3 retq
100000e62: 66 66 66 66 66 2e 0f data32 data32 data32 data32 nopw %cs:0x0(%rax,%rax,1)
100000e69: 1f 84 00 00 00 00 00
linux clang associates source line 20 (return return_value;) with (20) machine code bytes starting at address 40055c (shown below)
int
called_from_nodebug_actual(int some_value)
{
400530: 55 push %rbp
400531: 48 89 e5 mov %rsp,%rbp
400534: 48 83 ec 10 sub $0x10,%rsp
400538: 48 b8 d4 06 40 00 00 movabs $0x4006d4,%rax
40053f: 00 00 00
400542: 89 7d fc mov %edi,-0x4(%rbp)
int return_value = 0;
400545: c7 45 f8 00 00 00 00 movl $0x0,-0x8(%rbp)
return_value = printf ("Length: %d.\n", some_value);
40054c: 8b 75 fc mov -0x4(%rbp),%esi
40054f: 48 89 c7 mov %rax,%rdi
400552: b0 00 mov $0x0,%al
400554: e8 b7 fe ff ff callq 400410 <printf at plt>
400559: 89 45 f8 mov %eax,-0x8(%rbp)
return return_value; // Stop here and step out of me
40055c: 8b 45 f8 mov -0x8(%rbp),%eax
40055f: 48 83 c4 10 add $0x10,%rsp
400563: 5d pop %rbp
400564: c3 retq
400565: 66 66 2e 0f 1f 84 00 data32 nopw %cs:0x0(%rax,%rax,1)
40056c: 00 00 00 00
0000000000400570 <called_from_nodebug>:
}
the first 9 bytes of the associated machine code are identical for the mac and linux versions. the next 11 bytes are data bytes that are present in both the mac and linux versions of the object code, but only linux clang associates these with line 12.
in the unit test i was debugging, this difference didn’t cause a unit test failure, but it was disconcerting to see this difference between the mac and linux versions.
is this difference expected?
thanks,
doug
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20140721/2e0bd9e4/attachment.html>
More information about the cfe-dev
mailing list