[llvm-branch-commits] [llvm] X86: Make sure compiler-rt div calls are not added for msvc (PR #164591)
Matt Arsenault via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Oct 22 02:58:09 PDT 2025
https://github.com/arsenm created https://github.com/llvm/llvm-project/pull/164591
The current predicate system is primitive, we ought to have
a way to list a chain of alternatives.
>From c9b25df5c291552d42ef1e3de0d7cf8d3e077eab Mon Sep 17 00:00:00 2001
From: Matt Arsenault <Matthew.Arsenault at amd.com>
Date: Wed, 22 Oct 2025 16:30:46 +0900
Subject: [PATCH] X86: Make sure compiler-rt div calls are not added for msvc
The current predicate system is primitive, we ought to have
a way to list a chain of alternatives.
---
llvm/include/llvm/IR/RuntimeLibcalls.td | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.td
index 243b864ccf033..c9e08e844f2a0 100644
--- a/llvm/include/llvm/IR/RuntimeLibcalls.td
+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td
@@ -2450,6 +2450,11 @@ def _aullrem : RuntimeLibcallImpl<UREM_I64>;
def _allmul : RuntimeLibcallImpl<MUL_I64>;
}
+// FIXME: Should have utility function to filter by known provider.
+defvar WindowsDivRemMulLibcallOverrides = [
+ __divdi3, __udivdi3, __moddi3, __umoddi3, __muldi3
+];
+
//===----------------------------------------------------------------------===//
// X86 Runtime Libcalls
//===----------------------------------------------------------------------===//
@@ -2471,7 +2476,7 @@ defvar X86_F128_Libcalls = LibcallImpls<(add LibmF128Libcalls, LibmF128FiniteLib
defvar SinCosF32F64Libcalls = LibcallImpls<(add sincosf, sincos), hasSinCos_f32_f64>;
defvar X86CommonLibcalls =
- (add WinDefaultLibcallImpls,
+ (add (sub WinDefaultLibcallImpls, WindowsDivRemMulLibcallOverrides),
DarwinSinCosStret, DarwinExp10,
X86_F128_Libcalls,
LibmHasSinCosF80, // FIXME: Depends on long double
@@ -2494,10 +2499,15 @@ defvar Windows32DivRemMulCalls =
LibcallsWithCC<(add WindowsDivRemMulLibcalls), X86_STDCALL,
RuntimeLibcallPredicate<"TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment()">>;
+defvar NotWindows32DivRemMulCalls =
+ LibcallImpls<(add WindowsDivRemMulLibcallOverrides),
+ RuntimeLibcallPredicate<"!TT.isWindowsMSVCEnvironment() && !TT.isWindowsItaniumEnvironment()">>;
+
def X86_32SystemLibrary
: SystemRuntimeLibrary<isX86_32,
(add X86CommonLibcalls,
- Windows32DivRemMulCalls)>;
+ NotWindows32DivRemMulCalls,
+ Windows32DivRemMulCalls)>;
def X86_64SystemLibrary
: SystemRuntimeLibrary<isX86_64,
More information about the llvm-branch-commits
mailing list