[LLVMdev] There are compiling errors when converting bytecode to c by LLC

Fei Jia j.jiafei at gmail.com
Mon Oct 10 16:15:44 PDT 2011


I convert C to bytecode by LLVM, and then convert the bytecode back to C by
LLC, but the generated C code cannot be compiled. Could anyone give me some
suggestions? Thanks!

The initial C file is rather simple (hello world):

#include <stdio.h>

int main() {

        printf("hello world\n");

        printf("hello world1\n");

        return 0;

}


The two commands:

llvm-gcc -emit-llvm -c -o hello.bc hello.c

llc -march=c hello.bc

Version of LLVM: 2.9


The source of error in generated c file:

/* Global Variable Declarations */

static _OC_str { unsigned char array[12]; };

static _OC_str1 { unsigned char array[13]; };




/* Global Variable Definitions and Initialization */

static _OC_str { unsigned char array[12]; } = { "hello world" };

static _OC_str1 { unsigned char array[13]; } = { "hello world1" };


It seems that _OC_str, and _OC_str1 are structure variables, but I have
never seen such way of declarations, definitions, and initialization of
structure in C code. I guess it may be supported in some standards of C.
Could anyone please give me some information about the problem? Thanks!

--
Best Regards,
Fei Jia
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20111010/d326447e/attachment.html>


More information about the llvm-dev mailing list