This is the mail archive of the cygwin@cygwin.com mailing list for the Cygwin project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Is a function actually inlined?


========================================
Windows 2000 Professional
CYGWIN_NT-5.0 1.5.4(0.94/3/2)
GNU gcc version 3.3.1 (cygming special)
GNU nm 2.14.90 20030901
GNU objdump 2.14.90 20030901
=======================================


How can one know if a function requested to be inlined is actually inlined?

Here is an example.

Are the foo2() and foo3() functions actually inlined?

====== 1. C++ code : File t.cpp : BEGIN ======

struct Foo
{
  void foo1();
  void foo2() {} // requested to be inlined
  void foo3();
};
void Foo::foo1() {}
inline void Foo::foo3() {} // requested to be inlined

int main()
{
Foo ins;
  ins.foo1();
  ins.foo2();
  ins.foo3();
  return 0;
}

====== 1. C++ code : File t.cpp : END ========


====== 2. Compilation : BEGIN ======

$ g++ -save-temps t.cpp

====== 2. Compilation : END ========



====== 3. Analysis of the t.s file : BEGIN ======

$ grep foo t.s

.globl __ZN3Foo4foo1Ev
 .def __ZN3Foo4foo1Ev; .scl 2; .type 32; .endef
__ZN3Foo4foo1Ev:
 call __ZN3Foo4foo1Ev
 call __ZN3Foo4foo2Ev
 call __ZN3Foo4foo3Ev
 .section .text$_ZN3Foo4foo2Ev,"x"
.globl __ZN3Foo4foo2Ev
 .def __ZN3Foo4foo2Ev; .scl 2; .type 32; .endef
__ZN3Foo4foo2Ev:
 .section .text$_ZN3Foo4foo3Ev,"x"
.globl __ZN3Foo4foo3Ev
 .def __ZN3Foo4foo3Ev; .scl 2; .type 32; .endef
__ZN3Foo4foo3Ev:
 .def __ZN3Foo4foo3Ev; .scl 3; .type 32; .endef
 .def __ZN3Foo4foo2Ev; .scl 3; .type 32; .endef

====== 3. Analysis of the t.s file  : END ========



====== 4. Use of the nm utility : BEGIN ======

$ nm -C t.o

00000000 b .bss
00000000 d .data
00000000 t .text
00000000 t .text$_ZN3Foo4foo2Ev
00000000 t .text$_ZN3Foo4foo3Ev
00000000 T Foo::foo1()
00000000 T Foo::foo2()
00000000 T Foo::foo3()
         U __main
         U _alloca
00000006 T main

====== 4. Use of the nm utility : END ========




====== 5. Use of the objdump utility : BEGIN ======

$ objdump -CS t.o | grep foo

00000000 <Foo::foo1()>:
  2a: e8 d1 ff ff ff        call   0 <Foo::foo1()>
Disassembly of section .text$_ZN3Foo4foo2Ev:
00000000 <Foo::foo2()>:
Disassembly of section .text$_ZN3Foo4foo3Ev:
00000000 <Foo::foo3()>:



$ objdump -CS t.o | grep foo

  1a: e8 00 00 00 00        call   1f <main+0x19>
  1f: e8 00 00 00 00        call   24 <main+0x1e>
  2a: e8 d1 ff ff ff        call   0 <Foo::foo1()>
  35: e8 00 00 00 00        call   3a <main+0x34>
  40: e8 00 00 00 00        call   45 <main+0x3f>

====== 5. Use of the objdump utility : END ========


   =====================================
   Alex Vinokur
     mailto:alexvn@connect.to
     http://mathforum.org/library/view/10978.html
   =====================================








--
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple
Problem reports:       http://cygwin.com/problems.html
Documentation:         http://cygwin.com/docs.html
FAQ:                   http://cygwin.com/faq/


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]