Skip to content

Commit c9b25df

Browse files
committed
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.
1 parent 71b7a3e commit c9b25df

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
@@ -2450,6 +2450,11 @@ def _aullrem : RuntimeLibcallImpl<UREM_I64>;
24502450
def _allmul : RuntimeLibcallImpl<MUL_I64>;
24512451
}
24522452

2453+
// FIXME: Should have utility function to filter by known provider.
2454+
defvar WindowsDivRemMulLibcallOverrides = [
2455+
__divdi3, __udivdi3, __moddi3, __umoddi3, __muldi3
2456+
];
2457+
24532458
//===----------------------------------------------------------------------===//
24542459
// X86 Runtime Libcalls
24552460
//===----------------------------------------------------------------------===//
@@ -2471,7 +2476,7 @@ defvar X86_F128_Libcalls = LibcallImpls<(add LibmF128Libcalls, LibmF128FiniteLib
24712476
defvar SinCosF32F64Libcalls = LibcallImpls<(add sincosf, sincos), hasSinCos_f32_f64>;
24722477

24732478
defvar X86CommonLibcalls =
2474-
(add WinDefaultLibcallImpls,
2479+
(add (sub WinDefaultLibcallImpls, WindowsDivRemMulLibcallOverrides),
24752480
DarwinSinCosStret, DarwinExp10,
24762481
X86_F128_Libcalls,
24772482
LibmHasSinCosF80, // FIXME: Depends on long double
@@ -2494,10 +2499,15 @@ defvar Windows32DivRemMulCalls =
24942499
LibcallsWithCC<(add WindowsDivRemMulLibcalls), X86_STDCALL,
24952500
RuntimeLibcallPredicate<"TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment()">>;
24962501

2502+
defvar NotWindows32DivRemMulCalls =
2503+
LibcallImpls<(add WindowsDivRemMulLibcallOverrides),
2504+
RuntimeLibcallPredicate<"!TT.isWindowsMSVCEnvironment() && !TT.isWindowsItaniumEnvironment()">>;
2505+
24972506
def X86_32SystemLibrary
24982507
: SystemRuntimeLibrary<isX86_32,
24992508
(add X86CommonLibcalls,
2500-
Windows32DivRemMulCalls)>;
2509+
NotWindows32DivRemMulCalls,
2510+
Windows32DivRemMulCalls)>;
25012511

25022512
def X86_64SystemLibrary
25032513
: SystemRuntimeLibrary<isX86_64,

0 commit comments

Comments
 (0)