[llvm] [win][x64] Fix import call optimization for calls to dllimports and global function pointers (PR #160604)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 24 14:47:39 PDT 2025


================
@@ -2586,9 +2593,25 @@ void X86AsmPrinter::emitInstruction(const MachineInstr *MI) {
     break;
 
   case X86::CALL64m:
-    if (EnableImportCallOptimization && isCallToCFGuardFunction(MI)) {
-      emitLabelAndRecordForImportCallOptimization(
-          IMAGE_RETPOLINE_AMD64_CFG_CALL);
+    if (EnableImportCallOptimization) {
+      if (isCallToCFGuardFunction(MI)) {
+        emitLabelAndRecordForImportCallOptimization(
+            IMAGE_RETPOLINE_AMD64_CFG_CALL);
+      } else if (isImportedFunction(MI->getOperand(3))) {
----------------
efriedma-quic wrote:

This is referring to a CALL64m where the symbol is an `__imp_` symbol?

What happens if there's an indirect call to a function which isn't an imported function?  Or is that impossible because we don't have CALL64r_ImpCall?

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


More information about the llvm-commits mailing list