Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

RuntimeLibcalls: Fix calling conv of win32 div libcalls#149098

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Conversation

arsenm
Copy link
Contributor

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.

There's probably an existing test this should be added to,but our test coverage is really bad that this wasn't caughtby one.
@arsenmGraphite App
Copy link
ContributorAuthor

This stack of pull requests is managed byGraphite. Learn more aboutstacking.

@llvmbot
Copy link
Member

llvmbot commentedJul 16, 2025
edited
Loading

@llvm/pr-subscribers-llvm-ir
@llvm/pr-subscribers-platform-windows

@llvm/pr-subscribers-backend-x86

Author: Matt Arsenault (arsenm)

Changes

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.


Full diff:https://github.com/llvm/llvm-project/pull/149098.diff

2 Files Affected:

  • (modified) llvm/include/llvm/IR/RuntimeLibcalls.td (+1-1)
  • (added) llvm/test/CodeGen/X86/win32-int-runtime-libcalls.ll (+72)
diff --git a/llvm/include/llvm/IR/RuntimeLibcalls.td b/llvm/include/llvm/IR/RuntimeLibcalls.tdindex 11926d4128fcf..f0297cd1a0873 100644--- a/llvm/include/llvm/IR/RuntimeLibcalls.td+++ b/llvm/include/llvm/IR/RuntimeLibcalls.td@@ -2129,7 +2129,7 @@ defvar X86CommonLibcalls = );  defvar Windows32DivRemMulCalls =-  LibcallImpls<(add WindowsDivRemMulLibcalls),+  LibcallsWithCC<(add WindowsDivRemMulLibcalls), X86_STDCALL,   RuntimeLibcallPredicate<"TT.isWindowsMSVCEnvironment() || TT.isWindowsItaniumEnvironment()">>;  def X86_32SystemLibrarydiff --git a/llvm/test/CodeGen/X86/win32-int-runtime-libcalls.ll b/llvm/test/CodeGen/X86/win32-int-runtime-libcalls.llnew file mode 100644index 0000000000000..86f24ebf6ce86--- /dev/null+++ b/llvm/test/CodeGen/X86/win32-int-runtime-libcalls.ll@@ -0,0 +1,72 @@+; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 5+; RUN: llc -mtriple=i686-windows-msvc < %s | FileCheck %s++define i64 @test_sdiv_i64(i64 %a, i64 %b) {+; CHECK-LABEL: test_sdiv_i64:+; CHECK:       # %bb.0:+; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)+; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)+; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)+; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)+; CHECK-NEXT:    calll __alldiv+; CHECK-NEXT:    retl+  %ret = sdiv i64 %a, %b+  ret i64 %ret+}++define i64 @test_srem_i64(i64 %a, i64 %b) {+; CHECK-LABEL: test_srem_i64:+; CHECK:       # %bb.0:+; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)+; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)+; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)+; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)+; CHECK-NEXT:    calll __allrem+; CHECK-NEXT:    retl+  %ret = srem i64 %a, %b+  ret i64 %ret+}++define i64 @test_udiv_i64(i64 %a, i64 %b) {+; CHECK-LABEL: test_udiv_i64:+; CHECK:       # %bb.0:+; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)+; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)+; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)+; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)+; CHECK-NEXT:    calll __aulldiv+; CHECK-NEXT:    retl+  %ret = udiv i64 %a, %b+  ret i64 %ret+}++define i64 @test_urem_i64(i64 %a, i64 %b) {+; CHECK-LABEL: test_urem_i64:+; CHECK:       # %bb.0:+; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)+; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)+; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)+; CHECK-NEXT:    pushl {{[0-9]+}}(%esp)+; CHECK-NEXT:    calll __aullrem+; CHECK-NEXT:    retl+  %ret = urem i64 %a, %b+  ret i64 %ret+}++define i64 @test_mul_i64(i64 %a, i64 %b) {+; CHECK-LABEL: test_mul_i64:+; CHECK:       # %bb.0:+; CHECK-NEXT:    pushl %esi+; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %ecx+; CHECK-NEXT:    movl {{[0-9]+}}(%esp), %esi+; CHECK-NEXT:    movl %ecx, %eax+; CHECK-NEXT:    mull %esi+; CHECK-NEXT:    imull {{[0-9]+}}(%esp), %ecx+; CHECK-NEXT:    addl %ecx, %edx+; CHECK-NEXT:    imull {{[0-9]+}}(%esp), %esi+; CHECK-NEXT:    addl %esi, %edx+; CHECK-NEXT:    popl %esi+; CHECK-NEXT:    retl+  %ret = mul i64 %a, %b+  ret i64 %ret+}

@arsenmarsenm marked this pull request as ready for reviewJuly 16, 2025 13:31
Copy link
Member

@compnerdcompnerd left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Can you add a test for x64 that ensures that is also called correctly (no stdcall)?

Copy link
Member

@mstorsjomstorsjo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Thanks! This does fix all my observed issues.

@RKSimonRKSimon requested a review fromrnkJuly 16, 2025 16:22
@arsenmarsenm merged commit0110168 intomainJul 16, 2025
8 of 9 checks passed
@arsenmarsenm deleted the users/arsenm/runtime-libcalls/fix-callingconv-win32-div-libcalls branchJuly 16, 2025 23:29
@arsenmarsenm added this to theLLVM 21.x Release milestoneJul 17, 2025
@arsenm
Copy link
ContributorAuthor

/cherry-pick0110168

@llvmbot
Copy link
Member

/pull-request#149246

@llvmbotllvmbot moved this fromNeeds Triage toDone inLLVM Release StatusJul 17, 2025
nikic pushed a commit to nikic/llvm-project that referenced this pull requestJul 17, 2025
There's probably an existing test this should be added to,but our test coverage is really bad that this wasn't caughtby one.
tru pushed a commit to llvmbot/llvm-project that referenced this pull requestJul 17, 2025
There's probably an existing test this should be added to,but our test coverage is really bad that this wasn't caughtby one.(cherry picked from commit0110168)
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@compnerdcompnerdcompnerd approved these changes

@mstorsjomstorsjomstorsjo approved these changes

@RKSimonRKSimonAwaiting requested review from RKSimon

@rnkrnkAwaiting requested review from rnk

Assignees
No one assigned
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

4 participants
@arsenm@llvmbot@compnerd@mstorsjo

[8]ページ先頭

©2009-2025 Movatter.jp