how to fix this "Expected no forward declarations!" assertion fail

Hello, Everyone

I’m using llvm 3.6 DIBuilder module to build the debug information for Chapel language(the Chapel-llvm front end works fine). When I run the test program, I got these assertions failed:
Expected no forward declarations!
Expected no forward declarations!
Expected no forward declarations!
Expected no forward declarations!
All nodes should be resolved!

How should I debug it since the bitcode file isn’t generated and I can’t see what exactly those MDNodes represent…

Any information would be great appreciated, not found any useful posts online yet

Thanks a lot !

Did anyone have any experience with this issue before ? I didn’t have this issue when I used llvm 3.3

Can anyone shed some light on this ?


You can probably disable the pass that verifies the LLVM bitcode. If you’re using opt, there’s a command-line option for that (use --help-hidden to find it). If you’re using a custom tool, you’ll either need to find the option or modify its source code to disable it. Alternatively, run the program through a debugger so that you break into the debugger when it hits the assertion. You can then use the debugger to examine the IR (using the dump() methods of various LLVM classes) and see what is causing the problem. Regards, John Criswell

Hello, John

Yes. If the error isn’t too bad, you can probably get a malformed LLVM bitcode file that you can disassemble with llvm-dis and examine. Let’s say that gdb stops due to an assertion, and there’s a local variable of type Instruction * called inst. If you use the command “call inst->dump()” in gdb, it will call Instruction::dump() on inst, causing it to print out the instruction. Most LLVM classes (Instruction, BasicBlock, Function, Constant) have a dump() method that you can call to print the human-readable version of the object in the debugger. For more information on calling C++ methods in gdb, you can consult the gdb documentation. Regards, John Criswell