<html>
  <head>

    <meta http-equiv="content-type" content="text/html; charset=ISO-8859-1">
  </head>
  <body bgcolor="#FFFFFF" text="#000000">
    Hi all,<br>
    <br>
    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!<br>
    <br>
    With this simple program:<br>
    <b><br>
      #include <stdio.h><br>
      #include <string.h><br>
      <br>
      int main(int argc, char** argv){<br>
      <br>
          char a[8] = "aaaaaaa";<br>
          char b[8] = "bbbbbbb";<br>
      <br>
          char *c = (char*)
      malloc(sizeof(char)*(strlen(a)+strlen(b)+1));<br>
          memcpy(c, a, strlen(a));<br>
          memcpy(c + strlen(a), b, strlen(b) + 1);<br>
      <br>
          printf("a = %s, b = %s, c = %s\n", a, b, c);<br>
      }<br>
    </b><br>
    and compiling and executing in the following way:<br>
    <br>
    $> gcc -fplugin=~/dragonegg.so -O1
    -fplugin-arg-dragonegg-enable-gcc-optzns test.c -S
    -fplugin-arg-dragonegg-emit-ir -o test.ll<br>
    <br>
    $> lli test.ll<br>
    <br>
    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?<br>
    <br>
    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:<br>
    <br>
    $> llvm-link -S test.ll > test.ir<br>
    <br>
    $> llvm-as test.ir -o test.s<br>
    <br>
    <pre class="moz-signature" cols="72">-- 
Pablo Barrio
Dpt. Electrical Engineering - Technical University of Madrid
Office C-203
Avda. Complutense s/n, 28040 Madrid
Tel. (+34) 915495700 ext. 4234
@: <a class="moz-txt-link-abbreviated" href="mailto:pbarrio@die.upm.es">pbarrio@die.upm.es</a>
</pre>
  </body>
</html>