[LLVMdev] Possible bug in the dragonegg
Pablo Barrio
pbarrio at die.upm.es
Mon Jan 23 05:39:41 PST 2012
Hi all,
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? ¿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
$> 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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120123/62905179/attachment.html>
More information about the llvm-dev
mailing list