dimanche 29 mars 2015

investigating visual studio assembly output


While using /FA option for compiling code that uses this dummy class



class A {
public:
A() {}
int Initialize() {
return 0;
}
};


I looked over the generated asm file where this was defined and also used and saw this in the asm file



PUBLIC ?Initialize@A@@QEAAHXZ ; A::Initialize
PUBLIC ??0A@@QEAA@H@Z ; A::A

??0A@@QEAA@H@Z PROC ; A::A, COMDAT
; File d:\dev\temp\consoleapplication1\consoleapplication1\consoleapp2.cpp
; Line 7
mov rax, rcx
ret 0
??0A@@QEAA@H@Z ENDP ; A::A
_TEXT ENDS
; Function compile flags: /Ogtpy
; COMDAT ?Initialize@A@@QEAAHXZ
_TEXT SEGMENT
this$dead$ = 8
?Initialize@A@@QEAAHXZ PROC ; A::Initialize, COMDAT
; File d:\dev\temp\consoleapplication1\consoleapplication1\consoleapp2.cpp
; Line 9
xor eax, eax
; Line 10
ret 0
?Initialize@A@@QEAAHXZ ENDP ; A::Initialize


As you can see there is generated "trivial" implementation functions for both constructor and Initialize function.


At first I thought that this non inline implementation was going to be used where class A is used but debugging showed that this was not the case (code seemed to be inlined). Class A is not used anywhere else except this asm file so why are those functions generated if not used ?


Whole program optimization was in place.




Aucun commentaire:

Enregistrer un commentaire