Hello everyone, I've been trying to generate a C file using the llc tool, but I'm having a problem. I'm using a single Hello World program in C, and executing the following passes: clang -emit-llvm -c -o hello.bc hello.c # getting the bit code of hello.c llc -march=c hello.bc # generating the hello.cbe.c file using the llvm C backend So far, nothing weird happened. The problem occurs once I try to compile the hello.cbe.c: gcc, and even clang, show me some warning and error messages. Cheking in hello.cbe.c, I could see that the problem was related with the structs declarations and initialization. There, they appears to be something like /* Global Variable Declarations */ static _OC_str { unsigned char array[13]; }; /* Global Variable Definitions and Initialization */ static _OC_str { unsigned char array[13]; } = { "Hello World\n" }; when they should be like /* Global Variable Declarations */ static struct type_OC_str { unsigned char array[13]; }; /* Global Variable Definitions and Initialization */ static struct type_OC_str _OC_str = { "Hello World\n" }; It is a known problem, or am I doing something wrong? Thks in advance, -- Cristianno Martins PhD Student of Computer Science University of Campinas cmartins at ic.unicamp.br
Hello> It is a known problem, or am I doing something wrong?C backend is known to be buggy. -- With best regards, Anton Korobeynikov Faculty of Mathematics and Mechanics, Saint Petersburg State University
Hi Cristianno, This problem has been around for a while, ourselves we solve it with the following patches: https://hpcforge.org/scm/viewvc.php/trunk/patches/llvm.gpu.patch?root=kernelgen&view=markup https://hpcforge.org/scm/viewvc.php/trunk/patches/llvm.patch?revision=591&root=kernelgen&view=markup Please feel free to apply them, they *should* work for you even with the latest llvm 3.1. Also please feel free to ping me in case of any troubles. - D. ----- Original message -----> Hello everyone, > > I've been trying to generate a C file using the llc tool, but I'm > having a problem. I'm using a single Hello World program in C, and > executing the following passes: > > clang -emit-llvm -c -o hello.bc hello.c # getting the bit code of > hello.c llc -march=c hello.bc # generating the > hello.cbe.c file using the llvm C backend > > So far, nothing weird happened. The problem occurs once I try to > compile the hello.cbe.c: gcc, and even clang, show me some warning and > error messages. > Cheking in hello.cbe.c, I could see that the problem was related with > the structs declarations and initialization. There, they appears to be > something like > > /* Global Variable Declarations */ > static _OC_str { unsigned char array[13]; }; > > /* Global Variable Definitions and Initialization */ > static _OC_str { unsigned char array[13]; } = { "Hello World\n" > }; > > when they should be like > > /* Global Variable Declarations */ > static struct type_OC_str { unsigned char array[13]; }; > > /* Global Variable Definitions and Initialization */ > static struct type_OC_str _OC_str = { "Hello World\n" }; > > It is a known problem, or am I doing something wrong? > > Thks in advance, > > -- > Cristianno Martins > PhD Student of Computer Science > University of Campinas > cmartins at ic.unicamp.br > > _______________________________________________ > LLVM Developers mailing list > LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu > http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120305/7ba3d7ce/attachment.html>
Hello again, Thanks for the responses =) Dmitry, I have two points to comment: - First, I applied these two patches, and the .cbe.c file came out ok, except for one little thing -- the global variable was created with both modifiers: static and extern. Then, I just added a single guard to prevent this to happen (in a case of a variable having local linkage, the "extern" part was not printed to file). - Second, I created the patch appended in this email, but instead of representing only the "guard-adding" part, this patch is a union of this change, and the others two patches you sent to me. Thanks again, -- Cristianno Martins PhD Student of Computer Science University of Campinas cmartins at ic.unicamp.br On Mon, Mar 5, 2012 at 6:19 AM, Dmitry N. Mikushin <maemarcus at gmail.com> wrote:> Hi Cristianno, > > This problem has been around for a while, ourselves we solve it with the > following patches: > > https://hpcforge.org/scm/viewvc.php/trunk/patches/llvm.gpu.patch?root=kernelgen&view=markup > > https://hpcforge.org/scm/viewvc.php/trunk/patches/llvm.patch?revision=591&root=kernelgen&view=markup > > Please feel free to apply them, they *should* work for you even with the > latest llvm 3.1. Also please feel free to ping me in case of any troubles. > > - D. > > > > ----- Original message ----- >> Hello everyone, >> >> I've been trying to generate a C file using the llc tool, but I'm >> having a problem. I'm using a single Hello World program in C, and >> executing the following passes: >> >> clang -emit-llvm -c -o hello.bc hello.c # getting the bit code of >> hello.c llc -march=c hello.bc # generating the >> hello.cbe.c file using the llvm C backend >> >> So far, nothing weird happened. The problem occurs once I try to >> compile the hello.cbe.c: gcc, and even clang, show me some warning and >> error messages. >> Cheking in hello.cbe.c, I could see that the problem was related with >> the structs declarations and initialization. There, they appears to be >> something like >> >> /* Global Variable Declarations */ >> static _OC_str { unsigned char array[13]; }; >> >> /* Global Variable Definitions and Initialization */ >> static _OC_str { unsigned char array[13]; } = { "Hello >> World\n" >> }; >> >> when they should be like >> >> /* Global Variable Declarations */ >> static struct type_OC_str { unsigned char array[13]; }; >> >> /* Global Variable Definitions and Initialization */ >> static struct type_OC_str _OC_str = { "Hello World\n" }; >> >> It is a known problem, or am I doing something wrong? >> >> Thks in advance, >> >> -- >> Cristianno Martins >> PhD Student of Computer Science >> University of Campinas >> cmartins at ic.unicamp.br >> >> _______________________________________________ >> LLVM Developers mailing list >> LLVMdev at cs.uiuc.edu http://llvm.cs.uiuc.edu >> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev >-------------- next part -------------- A non-text attachment was scrubbed... Name: CBackend.patch Type: application/octet-stream Size: 20144 bytes Desc: not available URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120305/64ab34a2/attachment.obj>