[llvm] [GlobalOpt] Update debug info when changing CC to Fast (PR #144303)

Maurice Heumann via llvm-commits llvm-commits at lists.llvm.org
Thu Jul 3 04:05:45 PDT 2025


================
@@ -1920,6 +1920,14 @@ static void RemovePreallocated(Function *F) {
   }
 }
 
+static unsigned char GetDebugInfoFastCC(const Triple &Triple) {
+  if (Triple.isOSWindows() && Triple.isArch32Bit()) {
+    return llvm::dwarf::DW_CC_BORLAND_msfastcall;
+  }
+
+  return llvm::dwarf::DW_CC_normal;
+}
+
----------------
momo5502 wrote:

The decision how FastCC is being lowered happens here: https://github.com/llvm/llvm-project/blob/ec25a0568cfbd13a6e375d3a2295b706708d37c5/llvm/lib/Target/X86/X86CallingConv.td#L1062

Here is where the dwarf CC is translated to the CodeView format:
https://github.com/llvm/llvm-project/blob/ec25a0568cfbd13a6e375d3a2295b706708d37c5/llvm/lib/CodeGen/AsmPrinter/CodeViewDebug.cpp#L2005

I feel like the reason this issue arises in the first place is the redundancy for calling conventions: the information is stored in the function, as well as the debug info.

What would also work would be a pseudo dwarf calling convention for fastCC that can then be mapped onto the real CC for each respective platform. However, I assume that for most platforms this is just the normal calling convention, which is why this approach seemed to cause the least overhead.

https://github.com/llvm/llvm-project/pull/144303


More information about the llvm-commits mailing list