Skip to content
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

x86-64 va_arg instruction is not implemented correctly. #2112

Closed
llvmbot opened this issue Oct 24, 2007 · 9 comments
Closed

x86-64 va_arg instruction is not implemented correctly. #2112

llvmbot opened this issue Oct 24, 2007 · 9 comments
Labels
backend:X86 bugzilla Issues migrated from bugzilla

Comments

@llvmbot
Copy link
Collaborator

llvmbot commented Oct 24, 2007

Bugzilla Link 1740
Resolution FIXED
Resolved on Jan 04, 2013 11:31
Version 1.0
OS Linux
Blocks llvm/llvm-bugzilla-archive#6796 llvm/llvm-bugzilla-archive#2825
Reporter LLVM Bugzilla Contributor
CC @edwintorok,@sunfishcode

Extended Description

Using the LLVM 2.1 release, the following test case segfaults when run;

a.ll:

define i32 @​test(i32 %X, ...) {
%ap = alloca i8*, i32 1024
%ap2 = bitcast i8** %ap to i8*
call void @​llvm.va_start(i8* %ap2)
%tmp = va_arg i8** %ap, i32
call void @​llvm.va_end(i8* %ap2)
ret i32 %tmp
}

declare void @​llvm.va_start(i8*)
declare void @​llvm.va_end(i8*)

define i32 @​main(i32, i8**, i8**) {
%ret = call i32(i32, ...)* @​test(i32 0, i32 0)
ret i32 %ret
}

result:

$ llvm-as -f a.ll && llc -f a.bc && gcc a.s && ./a.out
Segmentation fault
$

@lattner
Copy link
Collaborator

lattner commented Feb 18, 2008

Verified on darwin/x86-64

@sunfishcode
Copy link
Member

There is currently no implementation of the x86-64 va_arg operation.
va_arg on x86-64 was going through the default legalize Expand logic,
generating code that was incorrect for x86-64. This has temporarily
been changed to a compiler abort, to avoid silently generating invalid
code.

llvm-gcc isn't affected because it doesn't currently use LLVM's va_arg
instruction on x86-64; it does the lowering before translating to LLVM.

@lattner
Copy link
Collaborator

lattner commented Oct 16, 2008

*** Bug llvm/llvm-bugzilla-archive#2825 has been marked as a duplicate of this bug. ***

@llvmbot
Copy link
Collaborator Author

llvmbot commented Nov 3, 2008

There is a similar problem when using i8 or i16 on x86-32:
these are passed in 4 byte wide stack slots (for the usual
calling convention at least), but the generic expansion
code increments the pointer by 1 (resp. 2) rather than 4.

@lattner
Copy link
Collaborator

lattner commented Feb 13, 2009

*** Bug llvm/llvm-bugzilla-archive#3569 has been marked as a duplicate of this bug. ***

@llvmbot
Copy link
Collaborator Author

llvmbot commented Jan 4, 2013

Works for me in llvm 3.3 (trunk 170352).

@lattner
Copy link
Collaborator

lattner commented Nov 26, 2021

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

@lattner
Copy link
Collaborator

lattner commented Nov 27, 2021

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

@EdSchouten
Copy link
Contributor

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

@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

4 participants