Skip to content

Win64 Does not codegen correctly alloca align 64 #9294

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
ZviRackover mannequin opened this issue Jan 6, 2011 · 5 comments
Closed

Win64 Does not codegen correctly alloca align 64 #9294

ZviRackover mannequin opened this issue Jan 6, 2011 · 5 comments
Labels
backend:X86 bugzilla Issues migrated from bugzilla

Comments

@ZviRackover
Copy link
Mannequin

ZviRackover mannequin commented Jan 6, 2011

Bugzilla Link 8922
Resolution FIXED
Resolved on Mar 09, 2011 05:11
Version trunk
OS Windows XP
Blocks llvm/llvm-bugzilla-archive#9100
Attachments Fix candidate patch, Reproducer test
CC @asl

Extended Description

The following test case produces the assertion below when running on the Win64 subtarget:

define noalias i32* @​factorial() nounwind readnone {
entry:
%a = alloca i32, align 64
ret i32* %a
}

Assertion failed: (-(Offset + StackSize)) % Align == 0, file ........\lib\Target\X86\X86FrameInfo.cpp, line 867

Explanation:

Win64 CodeGen adds an extra 32 bytes to frame size, to be used as a Red Zone for potential calls. This addition ruins the stack alignment in case the required alignment is greater than 32 bytes.

Proposed fix is to add max(32, MaxAlignment) bytes instead.
Attached are the testcase and patch.

@llvmbot
Copy link
Member

llvmbot commented Jan 7, 2011

I am planning to eliminate the block you attempt to patch.

See also;
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20101213/113852.html

Improved output is below;

factorial:
pushq %rbp
movq %rsp, %rbp
andq $-64, %rsp
subq $64, %rsp
leaq (%rsp), %rax
movq %rbp, %rsp
popq %rbp
ret

@ZviRackover
Copy link
Mannequin Author

ZviRackover mannequin commented Jan 8, 2011

I am planning to eliminate the block you attempt to patch.

See also;
http://lists.cs.uiuc.edu/pipermail/llvm-commits/Week-of-Mon-20101213/113852.html

Improved output is below;

factorial:
pushq %rbp
movq %rsp, %rbp
andq $-64, %rsp
subq $64, %rsp
leaq (%rsp), %rax
movq %rbp, %rsp
popq %rbp
ret

This looks right.
Please commit the attached test case as an indicator for this defect. It can remain as XFAIL until you commit your patch.

@llvmbot
Copy link
Member

llvmbot commented Jan 11, 2011

    andq    $-64, %rsp
    subq    $64, %rsp
    leaq    (%rsp), %rax

It would be suboptimal. We may do;

subq $4, %rsp ; or -8
andq $-64, %rsp
movq %rsp, %rax

It seems x86-codegen-generic issue. I will file one.

Anyway, I will add Zvi's testcase.

@llvmbot
Copy link
Member

llvmbot commented Mar 9, 2011

It has been fixed in r124949.
I have to file suboptimal alignment issue, thank you!

@llvmbot
Copy link
Member

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
augusto2112 added a commit to augusto2112/llvm-project that referenced this issue Sep 24, 2024
[lldb] Add test with custom alignment on a clang type
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