Skip to content

PDB shows wrong calling convention when compiling static functions on Windows x86 #144301

@momo5502

Description

@momo5502
Contributor

Compiling the following sample for Windows x86 with -O3 shows that static_func will have fastcc applied to it:

static __declspec(noinline) int static_func(int arg1){
	
	return arg1 * 2;
}

int main(int argc, char* argv[]) {
	return static_func(argc);
}

https://godbolt.org/z/Pcroj66c4

The PDB however shows NearC, so cdecl, instead of FastCall.

The reason this happens is because GlobalOpt updates the CC, but not the debug info:

F.setCallingConv(CallingConv::Fast);

I feel like the DISubroutineType should be updated to DW_CC_BORLAND_msfastcall for Windows x86. So that the PDB depicts the correct CC.

Activity

llvmbot

llvmbot commented on Jun 16, 2025

@llvmbot
Member

@llvm/issue-subscribers-debuginfo

Author: Maurice Heumann (momo5502)

Compiling the following sample for Windows x86 with -O3 shows that `static_func` will have `fastcc` applied to it:
static __declspec(noinline) int static_func(int arg1){
	
	return arg1 * 2;
}

int main(int argc, char* argv[]) {
	return static_func(argc);
}

https://godbolt.org/z/Pcroj66c4

The PDB however shows NearC, so cdecl, instead of FastCall.

The reason this happens is because GlobalOpt updates the CC, but not the debug info:

F.setCallingConv(CallingConv::Fast);

I feel like the DISubroutineType should be updated to DW_CC_BORLAND_msfastcall for Windows x86. So that the PDB depicts the correct CC.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @momo5502@zwuis@llvmbot

      Issue actions

        PDB shows wrong calling convention when compiling static functions on Windows x86 · Issue #144301 · llvm/llvm-project