bytecode reader assertion failure

I have a compiler transform that I have been working on that produces bytecode that passes the verifier. However, when I try to read that bytecode back in, I get the assertion failure below.

llvm::BytecodeReader::ParseConstantPoolValue(unsigned int):
Assertion `(!isa<Constant>(Result) || !cast<Constant>(Result)->isNullValue()) || !hasImplicitNull(TypeID) && "Cannot read null values from bytecode!"' failed.

So, I ran gdb on opt. I was able to get the following information from opt:

(gdb) print Result
$7 = (class llvm::Constant *) 0x96ad9d0
(gdb) call Result->dump()
  [41 x sbyte *] zeroinitializer
(gdb) print hasImplicitNull(TypeID)
$5 = true

Does anyone have any insight into what the problem is or how to go about fixing it? It seems diffcult to get context for what is going on, since the bytecode has not yet been fully read. Any help would be greatly appreciated!

The full output of the assertion failure is given below:

opt -simplifycfg -deadargelim -globaldce -verify -f -o /dev/null tmp.bc
opt: Reader.cpp:1978: llvm::Value* llvm::BytecodeReader::ParseConstantPoolValue(unsigned int): Assertion `(!isa<Constant>(Result) || !cast<Constant>(Result)->isNullValue()) || !hasImplicitNull(TypeID) && "Cannot read null values from bytecode!"' failed.
opt((anonymous namespace)::PrintStackTrace()+0x1a)[0x8645bae]
opt((anonymous namespace)::SignalHandler(int)+0x112)[0x8645e74]
[0xb87420]
/lib/libc.so.6(abort+0x101)[0x4cab64f1]
/lib/libc.so.6(__assert_fail+0xfd)[0x4caae859]
opt(llvm::BytecodeReader::ParseConstantPoolValue(unsigned int)+0x1b31)[0x856e825]
opt(llvm::BytecodeReader::ParseConstantPool(std::vector<llvm::BytecodeReader::ValueList*, std::allocator<llvm::BytecodeReader::ValueList*> >&, std::vector<llvm::PATypeHolder, std::allocator<llvm::PATypeHolder> >&, bool)+0x147)[0x856e985]
opt(llvm::BytecodeReader::ParseModule()+0x188)[0x856edfe]
opt(llvm::BytecodeReader::ParseBytecode(unsigned char const*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)+0x539)[0x856f6c1]
opt((anonymous namespace)::BytecodeFileReader::read(std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)+0xeb)[0x855b569]
opt(llvm::getBytecodeModuleProvider(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*, llvm::BytecodeHandler*)+0x93)[0x855b60b]
opt(llvm::ParseBytecodeFile(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> >*)+0x20)[0x855b88e]
opt(main+0x7e)[0x8378c90]
/lib/libc.so.6(__libc_start_main+0xdc)[0x4caa24e4]
opt(__gxx_personality_v0+0x149)[0x836bac1]

Regards,
Ryan

Ryan,

This looks like a bug. Could you file it, please?

Reid.

I am still diagnosing the cause of the assertion failure and will submit a bug when I better understand the problem.

Reid Spencer wrote:

I have further diagnosed the problem and submitted a bug report, which can be found at 1223 – verifier produces bytecode that causes a bytecode reader assertion failure My diagnosis is included in the bug report, if you're interested.

Thanks,
Ryan

Ryan M. Lefever wrote: