Error: Opaque pointers are only supported in -opaque-pointers mode

Please guide me to resolve the runtime error from my application. The error logs are as below:

`Opaque pointers are only supported in -opaque-pointers mode (Producer: 'LLVM15.0.7' Reader: 'LLVM 15.0.7')`

The above logs are triggered from the below code snippet of the application:

  auto buff = llvm::MemoryBuffer::getMemBuffer(LLVMIR, "", false);
  auto BC = llvm::parseBitcodeFile(*buff.get(), ctx);

maybe you’re reading bitcode w/ opaque pointers with an older version of LLVM?

From the documents, I can confirm that LLVM version 15 has support for opaque pointers by default. [Opaque Pointers — LLVM 17.0.0git documentation]

I did check my LLVM-IR code and I can also confirm that it doesn’t has a opaque pointer. Below is my LLVM-IR code:

    define i32 @main(i32 %_1328696, i8** %_1328701) {
        br label %return_1328637

        %_1328724 = phi i32 [ 42, %main_1328628 ]
        ret i32 %_1328724


On LLVM 15, you need to explicit call setOpaquePointers(true) on LLVMContext if you want to force-enable opaque pointers even when the input bitcode uses typed pointers. For example, this may be necessary if you are trying to mix typed and opaque bitcode files. If you are using only typed bitcode files or only opaque bitcode files, it should work without that.

On LLVM 16, typed bitcode is upgraded to opaque pointers by default.


Understood. Appreciate your help. :+1: