Domanda

On Windows x64, when is a compiler allowed to treat registers that the ABI marks as volatile as non-volatile given some additional insight? I have a disassembled function where r11 is used to restore the value of another register after a function call; when according to this, r11 itself is to considered volatile across function calls.

For example (from disassembled function):

myLibrary!MyClass::currentMemberFunction+0x18:
    call    myLibrary!MyClass::calledMemberFunction
    cmp     dword ptr [rsp+68h],0
    mov     rdi,rax
    je      myLibrary!MyClass::currentMemberFunction+0x58
    test    rbx,rbx
    mov     rcx,r11
    je      myLibrary!MyClass::currentMemberFunction+0x60

and

myLibrary!MyClass::currentMemberFunction+0x2f:
    call    myLibrary!MyClass::anotherCalledMemberFunction
    mov     rdx,rdi
    mov     rcx,r11
È stato utile?

Soluzione

These rules only apply when a call is made to a function that the code generator knows nothing about. Like a function in another translation unit that gets linked later. The calls you show however could well be in the same translation unit, given that the class name is the same. R11 is not volatile when the code generator knows that it isn't being modified. It could know.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top