LLVM Problem

Hello,

I am a presently doing undergraduate studies at IIIT-Delhi and have been trying to install LLVM and facing some issues installing it which you guys could help resolving. I am able to generate the byte code but unable to generate the assembly code from the byte code. Below is the commands that I executed along with the error.

clang hello.c -o hello

clang -O3 -emit-llvm hello.c -c -o hello.bc

llvm-dis < hello.bc | less
or
llc hello.bc -o hello.s

on running any of the last two lines I am getting an error which I an unable to resolve and understand:

llvm-dis: invalid module_code_globalvar record

Hoping for an early response.

Thanks
Paritosh Mittal

Hi,

an error which I an unable to resolve and understand:

llvm-dis: invalid module_code_globalvar record

As a first step you can try emitting LLVM assembly directly rather than using llvm-dis

$ clang -O3 -emit-llvm hello.c -S -o hello.ll

Hoping for an early response.

You’re more likely to get help if you provide more information.

  • What version of LLVM and clang are you using? E.g. from trunk? You should also be careful not to mix LLVM and clang versions (e.g. a bitcode file produced by clang 3.2 might not work properly with LLVM 3.4)

  • What are the contents of hello.c?
    If you don’t provide the source file nobody apart from you can try to reproduce the issue.

Thanks,
Dan