Skip to content

Commit bbf5c41

Browse files
authored
X86: Make sure compiler-rt div calls are not added for msvc (#164591)
The current predicate system is primitive, we ought to have a way to list a chain of alternatives.
1 parent 6b885c3 commit bbf5c41

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

llvm/include/llvm/IR/RuntimeLibcalls.td

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2452,6 +2452,11 @@ def _aullrem : RuntimeLibcallImpl<UREM_I64>;
24522452
def _allmul : RuntimeLibcallImpl<MUL_I64>;
24532453
}
24542454

2455+
// FIXME: Should have utility function to filter by known provider.
2456+
defvar WindowsDivRemMulLibcallOverrides = [
2457+
__divdi3, __udivdi3, __moddi3, __umoddi3, __muldi3
2458+
];
2459+
24552460
//===----------------------------------------------------------------------===//
24562461
// X86 Runtime Libcalls
24572462
//===----------------------------------------------------------------------===//
@@ -2473,7 +2478,7 @@ defvar X86_F128_Libcalls = LibcallImpls<(add LibmF128Libcalls, LibmF128FiniteLib
24732478
defvar SinCosF32F64Libcalls = LibcallImpls<(add sincosf, sincos), hasSinCos_f32_f64>;
24742479

24752480
defvar X86CommonLibcalls =
2476-
(add WinDefaultLibcallImpls,
2481+
(add (sub WinDefaultLibcallImpls, WindowsDivRemMulLibcallOverrides),
24772482
DarwinSinCosStret, DarwinExp10,
24782483
X86_F128_Libcalls,
24792484
LibmHasSinCosF80, // FIXME: Depends on long double
@@ -2496,10 +2501,15 @@ defvar Windows32DivRemMulCalls =
24962501
LibcallsWithCC<(add WindowsDivRemMulLibcalls), X86_STDCALL,
24972502
RuntimeLibcallPredicate<"TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment()">>;
24982503

2504+
defvar NotWindows32DivRemMulCalls =
2505+
LibcallImpls<(add WindowsDivRemMulLibcallOverrides),
2506+
RuntimeLibcallPredicate<"!TT.isWindowsMSVCEnvironment() && !TT.isWindowsItaniumEnvironment()">>;
2507+
24992508
def X86_32SystemLibrary
25002509
: SystemRuntimeLibrary<isX86_32,
25012510
(add X86CommonLibcalls,
2502-
Windows32DivRemMulCalls)>;
2511+
NotWindows32DivRemMulCalls,
2512+
Windows32DivRemMulCalls)>;
25032513

25042514
def X86_64SystemLibrary
25052515
: SystemRuntimeLibrary<isX86_64,

0 commit comments

Comments
 (0)