[LLVMdev] llvm-dis fails to parse bytecode emitted by clang

Lorenzo De Carli lorenzo at cs.wisc.edu
Mon Oct 25 15:05:25 PDT 2010


Hi,

I am trying to generate LLVM bytecode using CLANG and I ran into the
following problem. If I run clang with the -emit-llvm option and then
try to get a textual representation of the output using llvm-dis, the
latter crashes because of a failed assertion in BitCodeReader.cpp,
mentioning a "Type mismatch in value table" (the exact error message
is appended at the end of this email). However, if I generate the
bytecode from the same source using llvm-gcc instead of clang,
llvm-dis works fine.

I am also experiencing another (potentially unrelated problem). If I
try to run clang without the "-c" option (i.e. to generate an
executable instead of an object file) it crashes emitting the message
" clang: error: 'x86_64-unknown-linux-gnu': unable to pass LLVM
bit-code files to linker". Output for this problem is also attached.

Could anyone shed some light on those problem? I am using CLANG/LLVM
2.8 compiled from source. The test program I am trying to compile is
simply:

int main()
{
  return 0;
}


Thanks,
Lorenzo De Carli

Output for problem #1:
$ clang -c -emit-llvm test.c -o test.bc
$ llvm-dis test.bc
llvm-dis: BitcodeReader.cpp:205: llvm::Value*
llvm::BitcodeReaderValueList::getValueFwdRef(unsigned int, const
llvm::Type*): Assertion `(Ty == 0 || Ty == V->getType()) && "Type
mismatch in value table!"' failed.
0   llvm-dis  0x00000000006131c6
1   llvm-dis  0x0000000000613502
2   libc.so.6 0x00000039cf4302d0
3   libc.so.6 0x00000039cf430265 gsignal + 53
4   libc.so.6 0x00000039cf431d10 abort + 272
5   libc.so.6 0x00000039cf4296e6 __assert_fail + 246
6   llvm-dis  0x000000000051005b
llvm::BitcodeReaderValueList::getValueFwdRef(unsigned int, llvm::Type
const*) + 173
7   llvm-dis  0x000000000052e574
llvm::BitcodeReader::getFnValueByID(unsigned int, llvm::Type const*) +
42
8   llvm-dis  0x000000000051482b
llvm::BitcodeReader::ParseFunctionBody(llvm::Function*) + 11371
9   llvm-dis  0x000000000051574a
llvm::BitcodeReader::materializeFunction(llvm::Function*,
std::string*) + 284
10  llvm-dis  0x000000000050ddca
llvm::BitcodeReader::materializeModule(std::string*) + 210
11  llvm-dis  0x00000000005171b2
llvm::ParseBitcodeFile(llvm::MemoryBuffer*, std::string*) + 74
12  llvm-dis  0x000000000050b894 main + 160
13  libc.so.6 0x00000039cf41d994 __libc_start_main + 244
14  llvm-dis  0x000000000050b569 __gxx_personality_v0 + 625
Aborted

Output for problem #2:
$ clang -emit-llvm -c test.c [WORKS FINE]
$ clang -emit-llvm test.c
clang: error: 'x86_64-unknown-linux-gnu': unable to pass LLVM bit-code
files to linker



More information about the llvm-dev mailing list