[LLVMdev] OCaml binding: error with the function "has_metadata"

Jérémy Dubreil jeremy.dubreil at free.fr
Mon Jan 14 02:17:45 PST 2013


Hi all,

I am using the OCaml binding and I get the following error with the function "Llvm.has_metadata":

Assertion failed: (isa<X>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file .../llvm-3.2.src/include/llvm/Support/Casting.h, line 208.
Abort trap: 6

I am using the latest 3.2 release from the LLVM download page and this is a small code sample that is crashing, giving the error message above:

************************************

let load_module filename =
  let mb = Llvm.MemoryBuffer.of_file filename in
  Llvm_bitreader.parse_bitcode (Llvm.global_context ()) mb

let stats m =
  let print llvalue =
    if Llvm.has_metadata llvalue then
      Printf.printf "%s\n%!" (Llvm.value_name llvalue) in
  Llvm.iter_functions print m    
            
let _ =
  let m = load_module Sys.argv.(1) in
  stats m

*************************************

Does anbody know if I am doing something wrong ? or the OCaml binding is brocken for the function "has_metadata" ?

I have the same error on Linx (ubuntu 12.04) and MacOS 10.7.5. Also, I get the error with the release LLVM 3.1. I will check if I get the same thing with the version 3.0.

Regards,

Jeremy



More information about the llvm-dev mailing list