[LLVMdev] difference in function prologue generated with clang and gcc
anonymous
aspiringllvmdeveloper at gmail.com
Thu Feb 16 02:43:55 PST 2012
1.
I would like to know why there is a difference in function prologue
generated for same function with clang and gcc.
Compiler options used for gcc were as follows:
arm-linux-gnueabi-gcc all-types.c -w -march=armv7-a
-mtune=cortex-a8 -mfloat-abi=softfp -mfpu=vfp -g -lm -o all-types_gcc
Compiler options used for clang were as follows:
/usr/local/bin/clang all-types.c -w -ccc-gcc-name
arm-linux-gnueabi-gcc -ccc-host-triple arm-linux-gnueabi
-ccc-clang-archs arm -march=armv7-a -mtune=cortex-a8
-mfloat-abi=softfp -mfpu=vfp -g -lm -o all-types
Dissassembly of main() from all-types.c compiled with GCC.
00008448 <main>:
float v_float;
double v_double;
int main ()
{
8448: e92d4800 push {fp, lr}
844c: e28db004 add fp, sp, #4
extern void dummy();
#ifdef usestubs
set_debug_traps();
breakpoint();
#endif
dummy();
8450: eb000002 bl 8460 <dummy>
return 0;
8454: e3a03000 mov r3, #0
}
8458: e1a00003 mov r0, r3
845c: e8bd8800 pop {fp, pc}
00008460 <dummy>:
void dummy()
{
8460: e52db004 push {fp} ; (str fp,
[sp, #-4]!)
8464: e28db000 add fp, sp, #0
/* Some linkers (e.g. on AIX) remove unreferenced variables,
so make sure to reference them. */
v_char = 'A';
Raw dump of debug contents of section .debug_line:
Offset: 0x0
Length: 74
*DWARF Version: 2
* Prologue Length: 34
Minimum Instruction Length: 2
Initial value of 'is_stmt': 1
Line Base: -5
Line Range: 14
Opcode Base: 13
###################################################################################################################################
Dissassembly of main() from all-types.c compiled with CLANG.
00008444 <main>:
float v_float;
double v_double;
int main ()
{
8444: e92d4800 push {fp, lr}
8448: e1a0b00d mov fp, sp
844c: e24dd008 sub sp, sp, #8
8450: e3a00000 mov r0, #0
8454: e58d0004 str r0, [sp, #4]
extern void dummy();
#ifdef usestubs
set_debug_traps();
breakpoint();
#endif
dummy();
8458: e58d0000 str r0, [sp]
845c: eb000002 bl 846c <dummy>
return 0;
8460: e59d0000 ldr r0, [sp]
8464: e1a0d00b mov sp, fp
8468: e8bd8800 pop {fp, pc}
0000846c <dummy>:
}
void dummy()
{
846c: e3a00006 mov r0, #6
/* Some linkers (e.g. on AIX) remove unreferenced variables,
so make sure to reference them. */
v_char = 'A';
Raw dump of debug contents of section .debug_line:
Offset: 0x0
Length: 206
* DWARF Version: 2
* Prologue Length: 157
Minimum Instruction Length: 2
Initial value of 'is_stmt': 1
Line Base: -5
Line Range: 14
Opcode Base: 13
The prologue length in .debug_line is 157 for clang generated one,
whereas it is 34 for gcc generated one. I am curious about the results
of making prologue generated by clang look similar with one generated
by gcc.
Could anyone let me know why this difference exists and if it is
for good /better purposes than for gcc. ?
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120216/fd0b3a3a/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: all-types.c
Type: text/x-csrc
Size: 1056 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120216/fd0b3a3a/attachment.c>
More information about the llvm-dev
mailing list