Reid Spencer
2005-Mar-08 01:19 UTC
[LLVMdev] GCC assembler rejects native code generated by LLVM
Vyacheslav, This is the same problem that I had with Cygwin .. nearly identical. The issue was documented in PR492 if you want some background. I'm currently trying to dig up what I did to fix this in December for Cygwin and see if I can apply the same change for mingw. Reid. On Mon, 2005-03-07 at 16:39, Vyacheslav Akhmechet wrote:> Ok, I got home so I have more details. Here's the sample C program: > ----------------- C program --------------- > #include <stdio.h> > int main() { > printf("hello world\n"); > return 0; > } > ------------- end C program ------------- > > This is compiled using llvm online demo into the following llvm code > (target removed): > ----------------- LLVM code -------------- > deplibs = [ "stdc++", "c", "crtend" ] > %.str_1 = internal constant [13 x sbyte] c"hello world\0A\00"; <[13 x > sbyte]*> [#uses=1] > > implementation ; Functions: > > declare int %printf(sbyte*, ...) > > int %main() { > entry: > call void %__main( ) > %tmp.0 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([13 x > sbyte]* %.str_1, int 0, int 0) ); <int> [#uses=0] > ret int 0 > } > > declare void %__main() > ------------- End LLVM code ----------- > > which in turn produces the following assembly code: > > ------------- Assembly code ------------- > .text > .align 16 > .globl main > .type main, @function > main: > subl $12, %esp > fnstcw 10(%esp) > movb $2, 11(%esp) > fldcw 10(%esp) > call __main > movl $l1__2E_str_1, %eax > movl %eax, (%esp) > call printf > movl $0, %eax > #IMPLICIT_USE > addl $12, %esp > ret > > > .data > .align 1 > .type l1__2E_str_1, at object > .size l1__2E_str_1,13 > l1__2E_str_1: # [13 x sbyte]* %.str_1 = c"hello world\0A\00" > .ascii "hello world\n\000" > ---------- End assembly code ---------- > > When I try to assemble the above code using > gcc hello.c.s -o hello.exe > I get the following errors: > > hello.c.s: Assembler messages: > hello.c.s:6: Warning: .type pseudo-op used outside of .def/.endef ignored. > hello.c.s:6: Error: junk at end of line, first unrecognized character is `m' > hello.c.s:24: Warning: .type pseudo-op used outside of .def/.endef ignored. > hello.c.s:24: Error: junk at end of line, first unrecognized character is `l' > hello.c.s:25: Warning: .size pseudo-op used outside of .def/.endef ignored. > hello.c.s:25: Error: junk at end of line, first unrecognized character is `l' > > Sorry for the long email. I attach all relevant files for clarity. > > ______________________________________________________________________ > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050307/f34cdf94/attachment.sig>
Chris Lattner
2005-Mar-08 01:29 UTC
[LLVMdev] GCC assembler rejects native code generated by LLVM
On Mon, 7 Mar 2005, Reid Spencer wrote:> Vyacheslav, > This is the same problem that I had with Cygwin .. nearly identical. > The issue was documented in PR492 if you want some background. I'm > currently trying to dig up what I did to fix this in December for Cygwin > and see if I can apply the same change for mingw.You could extend the X86 backend's "getModuleMatchQuality" to match for both mingw and cygwin, instead of just cygwin... -Chris> On Mon, 2005-03-07 at 16:39, Vyacheslav Akhmechet wrote: >> Ok, I got home so I have more details. Here's the sample C program: >> ----------------- C program --------------- >> #include <stdio.h> >> int main() { >> printf("hello world\n"); >> return 0; >> } >> ------------- end C program ------------- >> >> This is compiled using llvm online demo into the following llvm code >> (target removed): >> ----------------- LLVM code -------------- >> deplibs = [ "stdc++", "c", "crtend" ] >> %.str_1 = internal constant [13 x sbyte] c"hello world\0A\00"; <[13 x >> sbyte]*> [#uses=1] >> >> implementation ; Functions: >> >> declare int %printf(sbyte*, ...) >> >> int %main() { >> entry: >> call void %__main( ) >> %tmp.0 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([13 x >> sbyte]* %.str_1, int 0, int 0) ); <int> [#uses=0] >> ret int 0 >> } >> >> declare void %__main() >> ------------- End LLVM code ----------- >> >> which in turn produces the following assembly code: >> >> ------------- Assembly code ------------- >> .text >> .align 16 >> .globl main >> .type main, @function >> main: >> subl $12, %esp >> fnstcw 10(%esp) >> movb $2, 11(%esp) >> fldcw 10(%esp) >> call __main >> movl $l1__2E_str_1, %eax >> movl %eax, (%esp) >> call printf >> movl $0, %eax >> #IMPLICIT_USE >> addl $12, %esp >> ret >> >> >> .data >> .align 1 >> .type l1__2E_str_1, at object >> .size l1__2E_str_1,13 >> l1__2E_str_1: # [13 x sbyte]* %.str_1 = c"hello world\0A\00" >> .ascii "hello world\n\000" >> ---------- End assembly code ---------- >> >> When I try to assemble the above code using >> gcc hello.c.s -o hello.exe >> I get the following errors: >> >> hello.c.s: Assembler messages: >> hello.c.s:6: Warning: .type pseudo-op used outside of .def/.endef ignored. >> hello.c.s:6: Error: junk at end of line, first unrecognized character is `m' >> hello.c.s:24: Warning: .type pseudo-op used outside of .def/.endef ignored. >> hello.c.s:24: Error: junk at end of line, first unrecognized character is `l' >> hello.c.s:25: Warning: .size pseudo-op used outside of .def/.endef ignored. >> hello.c.s:25: Error: junk at end of line, first unrecognized character is `l' >> >> Sorry for the long email. I attach all relevant files for clarity. >> >> ______________________________________________________________________ >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev >-Chris -- http://nondot.org/sabre/ http://llvm.cs.uiuc.edu/
Reid Spencer
2005-Mar-08 01:39 UTC
[LLVMdev] GCC assembler rejects native code generated by LLVM
My first patch was a little premature, please use this one. On Mon, 2005-03-07 at 17:19, Reid Spencer wrote:> Vyacheslav, > > This is the same problem that I had with Cygwin .. nearly identical. > The issue was documented in PR492 if you want some background. I'm > currently trying to dig up what I did to fix this in December for Cygwin > and see if I can apply the same change for mingw. > > Reid. > > On Mon, 2005-03-07 at 16:39, Vyacheslav Akhmechet wrote: > > Ok, I got home so I have more details. Here's the sample C program: > > ----------------- C program --------------- > > #include <stdio.h> > > int main() { > > printf("hello world\n"); > > return 0; > > } > > ------------- end C program ------------- > > > > This is compiled using llvm online demo into the following llvm code > > (target removed): > > ----------------- LLVM code -------------- > > deplibs = [ "stdc++", "c", "crtend" ] > > %.str_1 = internal constant [13 x sbyte] c"hello world\0A\00"; <[13 x > > sbyte]*> [#uses=1] > > > > implementation ; Functions: > > > > declare int %printf(sbyte*, ...) > > > > int %main() { > > entry: > > call void %__main( ) > > %tmp.0 = call int (sbyte*, ...)* %printf( sbyte* getelementptr ([13 x > > sbyte]* %.str_1, int 0, int 0) ); <int> [#uses=0] > > ret int 0 > > } > > > > declare void %__main() > > ------------- End LLVM code ----------- > > > > which in turn produces the following assembly code: > > > > ------------- Assembly code ------------- > > .text > > .align 16 > > .globl main > > .type main, @function > > main: > > subl $12, %esp > > fnstcw 10(%esp) > > movb $2, 11(%esp) > > fldcw 10(%esp) > > call __main > > movl $l1__2E_str_1, %eax > > movl %eax, (%esp) > > call printf > > movl $0, %eax > > #IMPLICIT_USE > > addl $12, %esp > > ret > > > > > > .data > > .align 1 > > .type l1__2E_str_1, at object > > .size l1__2E_str_1,13 > > l1__2E_str_1: # [13 x sbyte]* %.str_1 = c"hello world\0A\00" > > .ascii "hello world\n\000" > > ---------- End assembly code ---------- > > > > When I try to assemble the above code using > > gcc hello.c.s -o hello.exe > > I get the following errors: > > > > hello.c.s: Assembler messages: > > hello.c.s:6: Warning: .type pseudo-op used outside of .def/.endef ignored. > > hello.c.s:6: Error: junk at end of line, first unrecognized character is `m' > > hello.c.s:24: Warning: .type pseudo-op used outside of .def/.endef ignored. > > hello.c.s:24: Error: junk at end of line, first unrecognized character is `l' > > hello.c.s:25: Warning: .size pseudo-op used outside of .def/.endef ignored. > > hello.c.s:25: Error: junk at end of line, first unrecognized character is `l' > > > > Sorry for the long email. I attach all relevant files for clarity. > > > > ______________________________________________________________________ > > _______________________________________________ > > LLVM Developers mailing list > > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev > > ______________________________________________________________________ > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://mail.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- Index: X86AsmPrinter.cpp ==================================================================RCS file: /var/cvs/llvm/llvm/lib/Target/X86/X86AsmPrinter.cpp,v retrieving revision 1.132 diff -r1.132 X86AsmPrinter.cpp 87c87,88 < forCygwin = TT.find("cygwin") != std::string::npos; ---> forCygwin = TT.find("cygwin") != std::string::npos || > TT.find("mingw") != std::string::npos;89c90 < #ifdef __CYGWIN__ ---> #if defined(__CYGWIN__) || defined(__MINGW32__)-------------- next part -------------- A non-text attachment was scrubbed... Name: signature.asc Type: application/pgp-signature Size: 189 bytes Desc: This is a digitally signed message part URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20050307/487ee894/attachment.sig>
I'm trying to turn some GenericValues into Constants in the interpreter using code like this, in a switch statement: case Type::IntTyID: SI = ConstantSInt::get(FB->getType(), ArgVals[i].IntVal); params.push_back(UI); UI->dump(); //for testing break; FB is a Function::ArgumentListType::iterator ArgVals is a std::vector<GenericValue> the switch is on FB->getType()->getTypeID() so basically what I am doing is iterating through the formal argument list and using that to know how to convert the GenericValues (on a side note I can't get it to create iterators for ArgVals, hence the often n time operator[]) The dump() call causes a segfault and I can't figure out why. I looked at the implementation of get and it is supposed to create the constant if it does not already exist in the module, so I'm at a complete loss.
Seemingly Similar Threads
- [LLVMdev] GCC assembler rejects native code generated by LLVM
- [LLVMdev] GCC assembler rejects native code generated by LLVM
- [LLVMdev] GCC assembler rejects native code generated by LLVM
- [LLVMdev] GCC assembler rejects native code generated by LLVM
- [LLVMdev] GCC assembler rejects native code generated by LLVM