Skip to content

Commit 2087c26

Browse files
committed
RuntimeLibcalls: Fix calling conv of win32 div libcalls
There's probably an existing test this should be added to, but our test coverage is really bad that this wasn't caught by one.
1 parent 8710387 commit 2087c26

File tree

2 files changed

+73
-1
lines changed

2 files changed

+73
-1
lines changed

llvm/include/llvm/IR/RuntimeLibcalls.td

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2129,7 +2129,7 @@ defvar X86CommonLibcalls =
21292129
);
21302130

21312131
defvar Windows32DivRemMulCalls =
2132-
LibcallImpls<(add WindowsDivRemMulLibcalls),
2132+
LibcallsWithCC<(add WindowsDivRemMulLibcalls), X86_STDCALL,
21332133
RuntimeLibcallPredicate<"TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment()">>;
21342134

21352135
def X86_32SystemLibrary
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5
2+
; RUN: llc -mtriple=i686-windows-msvc < %s | FileCheck %s
3+
4+
define i64 @test_sdiv_i64(i64 %a, i64 %b) {
5+
; CHECK-LABEL: test_sdiv_i64:
6+
; CHECK: # %bb.0:
7+
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
8+
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
9+
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
10+
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
11+
; CHECK-NEXT: calll __alldiv
12+
; CHECK-NEXT: retl
13+
%ret = sdiv i64 %a, %b
14+
ret i64 %ret
15+
}
16+
17+
define i64 @test_srem_i64(i64 %a, i64 %b) {
18+
; CHECK-LABEL: test_srem_i64:
19+
; CHECK: # %bb.0:
20+
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
21+
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
22+
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
23+
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
24+
; CHECK-NEXT: calll __allrem
25+
; CHECK-NEXT: retl
26+
%ret = srem i64 %a, %b
27+
ret i64 %ret
28+
}
29+
30+
define i64 @test_udiv_i64(i64 %a, i64 %b) {
31+
; CHECK-LABEL: test_udiv_i64:
32+
; CHECK: # %bb.0:
33+
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
34+
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
35+
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
36+
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
37+
; CHECK-NEXT: calll __aulldiv
38+
; CHECK-NEXT: retl
39+
%ret = udiv i64 %a, %b
40+
ret i64 %ret
41+
}
42+
43+
define i64 @test_urem_i64(i64 %a, i64 %b) {
44+
; CHECK-LABEL: test_urem_i64:
45+
; CHECK: # %bb.0:
46+
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
47+
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
48+
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
49+
; CHECK-NEXT: pushl {{[0-9]+}}(%esp)
50+
; CHECK-NEXT: calll __aullrem
51+
; CHECK-NEXT: retl
52+
%ret = urem i64 %a, %b
53+
ret i64 %ret
54+
}
55+
56+
define i64 @test_mul_i64(i64 %a, i64 %b) {
57+
; CHECK-LABEL: test_mul_i64:
58+
; CHECK: # %bb.0:
59+
; CHECK-NEXT: pushl %esi
60+
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %ecx
61+
; CHECK-NEXT: movl {{[0-9]+}}(%esp), %esi
62+
; CHECK-NEXT: movl %ecx, %eax
63+
; CHECK-NEXT: mull %esi
64+
; CHECK-NEXT: imull {{[0-9]+}}(%esp), %ecx
65+
; CHECK-NEXT: addl %ecx, %edx
66+
; CHECK-NEXT: imull {{[0-9]+}}(%esp), %esi
67+
; CHECK-NEXT: addl %esi, %edx
68+
; CHECK-NEXT: popl %esi
69+
; CHECK-NEXT: retl
70+
%ret = mul i64 %a, %b
71+
ret i64 %ret
72+
}

0 commit comments

Comments
 (0)