This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Updated LLVM+GCC Patch

Hi Everyone,

Here is an updated version of the LLVM/GCC integration patch I've been working on. Relative to the last patch, this one features:

1. Better support for many builtins, including builtin returnaddress, frameaddress, prefetch, stacksave/restore, memcpy, etc.
2. Structure layout is now *right*, including bitfield layout and variable sized member in structures. This fixes the previous bitfield layout issues and implements static global initialization of bitfields/VLAs.
3. stacksave/restore have been implemented in LLVM and its code generators for full (backend) C99 VLA support.
4. "int A[2]; int*B = &A[1];" works.
5. This adds a new -emit-llvm option to the compiler, causing an LLVM ".ll" file to be emitted to the .s file instead of native machine code, the first step to supporting link-time optimization/codegen. This only is useful when combined with -S right now, as the driver still invokes the native assembler, which obviously doesn't grok LLVM assembly.
6. This adds support for file-scope inline asm blocks, but no other inline asm yet.

Finally this fixes a small collection of other random bugs, including a dangling pointer problem in the type layout code and several bitfield accessing issues.

This compiler works quite well for me, building large code bases and passing the LLVM test-suite (except for C++ EH). When I have some of the features below implemented I will start running the GCC test-suite.

So, now that the basics are here, what is missing? The major missing pieces are:

1. No debug support. This doesn't even have line number support yet. LLVM debug support as a whole is improving by leaps and bounds, so this will probably not be far off now.
2. ASM_EXPR is rejected. My current task is to implement the rest of inline asm support in LLVM. Doing so will also fix some of the ugly parts of this patch that #ifdef out inline asm code.
3. Dwarf exception handling isn't supported by the LLVM code generator, and isn't emitted by the front-end yet. This will be my task immediately after #2 is done, at which point I'll complete the implementation of C++ exception throwing/catching.
4. Vector support is still very basic. Generic vector support seems to work well, but no target intrinsics are passed through yet. This part will be picked up by other people unless I finish #2/#3 first.

I have only tested this work on PowerPC/darwin with C/objc/c++, so I'd be happy to have others try it out and report problems to me. Here are the basic instructions for using this:

1. Decide whether you want a checking-enabled compiler or not. Checking slows down compiles substantially, but is useful for debugging.
2. Get LLVM CVS and build it 'make tools-only' for a checking build, 'make tools-only ENABLE_OPTIMIZED=1' for a non-checking build.
3. Download this GCC SVN branch "svn:// apple/trunk/gcc", revision 108127.
4. Configure GCC SVN with "--enable-languages=c,objc,c++ --enable- llvm=<llvmobjroot>" and with "--enable-checking" if you want a checking enabled build. Also specify "--prefix=...", "--program- prefix=llvm-" or any other arguments you want.
5. I use 'make; make install' to get a working tree.

At this point you should have an LLVM-enabled GCC. As a simple "demo", you should be able to do this (to tell that it is llvm enabled):

$ <prefix>/bin/gcc -v
gcc version 4.0.1 LLVM (Apple Computer, Inc. build 5400)
$ echo 'int main() { puts("hello world"); }' > test.c
$ <prefix>/bin/gcc test.c -O
$ ./a.out
hello world
$ <prefix>/bin/gcc test.c -emit-llvm -O -S -o -
; ModuleID = 'test.c'
target endian = big
target pointersize = 32
target triple = "powerpc-apple-darwin8.2.0"
%str = internal constant [12 x sbyte] c"hello world\00" ; < [12 x sbyte]*> [#uses=1]

implementation ; Functions:

int %main() {
%tmp = call int %puts( sbyte* getelementptr ([12 x sbyte]* % str, int 0, uint 0) ) ; <int> [#uses=0]
ret int undef

declare int %puts(sbyte*)

As mentioned, my testing has been thorough on PPC/darwin, but I haven't tried any other target. I'd be happy to get reports of how well things work on other targets, and any other bugs people run into. Note that this all currently uses the native LLVM code generators, so it will only support targets that LLVM natively supports. Further, gcc/ (see LLVMTARGETOBJCMD) currently only knows about X86 and PowerPC, so basically the only other targets it makes sense to try right now is linux/i386.

When I'm done with inline asm and dwarf exceptions, I will start getting this reviewed and trying to push bits and pieces of this into the (apple) GCC tree.


Attachment: llvm-gcc.patch.7.txt.gz
Description: GNU Zip compressed data

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]