https://llvm.org/bugs/show_bug.cgi?id=23240

            Bug ID: 23240
           Summary: Less efficient stack adjustment code with -g
           Product: libraries
           Version: trunk
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P
         Component: Backend: X86
          Assignee: [email protected]
          Reporter: [email protected]
                CC: [email protected]
    Classification: Unclassified

Enabling debug info results in larger code at address 0x13. Without -g a 1 byte
pop instruction is used, with -g a 4 byte add is used to adjust the stack
pointer. Guessing that this is in the X86 backend.

Reduced from Burg in the llvm-test-suite. With revision r234984.

$ cat lex.c
int a;
int fn2();
int fn1() {
  int b;
  if ((b = fn2()) == '\n')
    a++;
  return b;
}
$ clang -c -O1 lex.c -o lex.o && objdump -d lex.o

lex.o:     file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <fn1>:
   0:   50                      push   %rax
   1:   31 c0                   xor    %eax,%eax
   3:   e8 00 00 00 00          callq  8 <fn1+0x8>
   8:   83 f8 0a                cmp    $0xa,%eax
   b:   75 06                   jne    13 <fn1+0x13>
   d:   ff 05 00 00 00 00       incl   0x0(%rip)        # 13 <fn1+0x13>
  13:   5a                      pop    %rdx
  14:   c3                      retq
$ clang -c -O1 lex.c -o lex_g.o -g && objdump -d lex_g.o

lex_g.o:     file format elf64-x86-64

Disassembly of section .text:

0000000000000000 <fn1>:
   0:   50                      push   %rax
   1:   31 c0                   xor    %eax,%eax
   3:   e8 00 00 00 00          callq  8 <fn1+0x8>
   8:   83 f8 0a                cmp    $0xa,%eax
   b:   75 06                   jne    13 <fn1+0x13>
   d:   ff 05 00 00 00 00       incl   0x0(%rip)        # 13 <fn1+0x13>
  13:   48 83 c4 08             add    $0x8,%rsp
  17:   c3                      retq

-- 
You are receiving this mail because:
You are on the CC list for the bug.
_______________________________________________
LLVMbugs mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/llvmbugs

Reply via email to