Skip to content

[Win64] incorrect stack frame with alloca(n) and call #9150

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
llvmbot opened this issue Dec 13, 2010 · 3 comments
Closed

[Win64] incorrect stack frame with alloca(n) and call #9150

llvmbot opened this issue Dec 13, 2010 · 3 comments
Labels
backend:X86 bugzilla Issues migrated from bugzilla

Comments

@llvmbot
Copy link
Member

llvmbot commented Dec 13, 2010

Bugzilla Link 8778
Resolution FIXED
Resolved on Mar 28, 2011 00:25
Version trunk
OS Windows XP
Blocks llvm/llvm-bugzilla-archive#9100
Reporter LLVM Bugzilla Contributor

Extended Description

define i64 @​foo(i64 %n) nounwind {
entry:
%buf = alloca i8, i64 %n, align 1
%r = call i64 @​bar(i8* %buf, i64 %n, i64 %n, i64 %n, i64 %n) nounwind
ret i64 %r
}
declare i64 @​bar(i8* nocapture, i64, i64, i64, i64) nounwind

$ llc -mtriple=x86_64-win32
foo:
pushq %rbp
movq %rsp, %rbp
subq $32, %rsp
movq %rcx, %rdx
leaq 15(%rdx), %rax
andq $-16, %rax
movq %rsp, %rcx
subq %rax, %rcx ;;; @​bar: 1st arg
movq %rcx, %rsp
subq $16, %rsp ;;; 40 (or aligned 48) bytes would be needed
movq %rdx, 32(%rsp) ;;; it might be on %buf
movq %rdx, %r8
movq %rdx, %r9
callq bar ;;; 32 bytes home area overlaps to %buf
movq %rbp, %rsp
popq %rbp
ret

Even when @​bar() has args less than 4, stack frame would be incorrect.

@llvmbot
Copy link
Member Author

llvmbot commented Feb 11, 2011

Fixed in r124949. (chkstk issue is pending)

foo:
pushq %rbp
movq %rsp, %rbp
movq %rcx, %rdx
leaq 15(%rdx), %rax
andq $-16, %rax
movq %rsp, %rcx
subq %rax, %rcx
movq %rcx, %rsp
subq $48, %rsp
movq %rdx, 32(%rsp)
movq %rdx, %r8
movq %rdx, %r9
callq bar
movq %rbp, %rsp
popq %rbp
ret

@llvmbot
Copy link
Member Author

llvmbot commented Mar 28, 2011

___chkstk is now emitted in r128206.

@llvmbot
Copy link
Member Author

llvmbot commented Nov 27, 2021

mentioned in issue llvm/llvm-bugzilla-archive#9100

@llvmbot llvmbot transferred this issue from llvm/llvm-bugzilla-archive Dec 3, 2021
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backend:X86 bugzilla Issues migrated from bugzilla
Projects
None yet
Development

No branches or pull requests

1 participant