[LLVMdev] Problem using march=c

Dmitry N. Mikushin maemarcus at gmail.com
Mon Mar 5 05:16:08 PST 2012


Hi Cristianno,

Great to know it works for you! Btw it would be very nice if someone could
help cleaning these fixes from CUDA/OpenCL stuff and contribute patch to
trunk, finally, with some tests.

> the global variable was created with both modifiers: static and extern.

Oh, right, this is wrong in general, was there just to unify behavior with
the cudafe source preprocessor, which does the same thing, since on GPU
global variables could not be shared between compilation units.

- D.

2012/3/5 Cristianno Martins <cristiannomartins at gmail.com>

> 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 --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120305/4bae2888/attachment.html>


More information about the llvm-dev mailing list