[LLVMdev] Possible bug in the dragonegg

Duncan Sands baldrick at free.fr
Mon Jan 23 06:58:51 PST 2012


Hi Pablo,

> I came across something that seems to be a bug in the dragonegg option that
> emits LLVM IR. ¿Can anybody reproduce the error, or see what's wrong?

I can't reproduce this on x86-64 linux with latest LLVM+dragonegg+gcc-4.6.

  ¿Should I
> post it somewhere else in case it's really a bug? Thanks ahead!
>
> With this simple program:
> *
> #include <stdio.h>
> #include <string.h>
>
> int main(int argc, char** argv){
>
> char a[8] = "aaaaaaa";
> char b[8] = "bbbbbbb";
>
> char *c = (char*) malloc(sizeof(char)*(strlen(a)+strlen(b)+1));
> memcpy(c, a, strlen(a));
> memcpy(c + strlen(a), b, strlen(b) + 1);
>
> printf("a = %s, b = %s, c = %s\n", a, b, c);
> }
> *
> and compiling and executing in the following way:
>
> $> gcc -fplugin=~/dragonegg.so -O1 -fplugin-arg-dragonegg-enable-gcc-optzns
> test.c -S -fplugin-arg-dragonegg-emit-ir -o test.ll

What happens if you compile without -fplugin-arg-dragonegg-enable-gcc-optzns?
Also, what is the contents of test.ll?

Ciao, Duncan.

>
> $> lli test.ll
>
> it segfaults. If I compile without "-S -fplugin-arg-dragonegg-emit-ir",
> everything's fine. Also, if I add "-force-interpreter=true" as an lli parameter,
> I get a "LLVM ERROR: Tried to execute an unknown external function: memcpy".
> Amazingly, if I change the string sizes below 8 (e.g. char a[7], char b[7]),
> everything works just fine!! It also works if I move a and b outside the
> function (as a global), or if I malloc the arrays. Possibly a problem of
> allocation of local vars in the stack?
>
> I also tried to link and create an assembler file so the interpreter could
> resolve the memcpy call, but neither of them work with lli:
>
> $> llvm-link -S test.ll > test.ir
>
> $> llvm-as test.ir -o test.s
>
> --
> Pablo Barrio
> Dpt. Electrical Engineering - Technical University of Madrid
> Office C-203
> Avda. Complutense s/n, 28040 Madrid
> Tel. (+34) 915495700 ext. 4234
> @:pbarrio at die.upm.es  <mailto:pbarrio at die.upm.es>
>
>
>
> _______________________________________________
> LLVM Developers mailing list
> LLVMdev at cs.uiuc.edu         http://llvm.cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvmdev




More information about the llvm-dev mailing list