Help Needed: LLVM IR Parsing Error

Hi everyone,

I’ve recently started working with LLVM and I’m running into an issue that I can’t seem to figure out. I’m getting the following error when trying to parse my LLVM IR code:

LLVM IR Parsing Error: expected instruction opcode

Here’s a snippet of the IR code that’s causing the issue:

define i32 @main() {
entry:
  %0 = add i32 1, 2
  ret i32 %0
}

When I was searching about this, I came across to these resources/articles LLVM IR parse error when the llvmlite dependency from 0.36.0 to 0.40.0 (llvm upgrade to 14) AWS DevOps Certification Path python 3.x - Numba: LLVM IR parsing error when trying to access elements in a typed list of jitted functions - Stack Overflow, and as per them I’ve double-checked the syntax and everything seems fine to me, but I must be missing something.

Has anyone encountered this error before? Any suggestions on how to debug or resolve this would be greatly appreciated.

Thanks in advance!

Best Regards

This parses perfectly fine with opt from LLVM 16 as well as LLVM HEAD. How are you attempting to parse this and what version of the tool are you using?