[OCaml] Don't truncate constants over 32 bits in Llvm.const_int.
authorPeter Zotov <whitequark@whitequark.org>
Tue, 22 Jul 2014 13:55:20 +0000 (13:55 +0000)
committerPeter Zotov <whitequark@whitequark.org>
Tue, 22 Jul 2014 13:55:20 +0000 (13:55 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213655 91177308-0d34-0410-b5e6-96231b3b80d8

bindings/ocaml/llvm/llvm_ocaml.c
test/Bindings/Ocaml/bitwriter.ml
test/Bindings/Ocaml/vmcore.ml

index d5ebdcd3e31af05ca37a779619378329a2b9734d..2044856ef2dabd921f1a12f7613856b6038e1d77 100644 (file)
@@ -695,7 +695,7 @@ CAMLprim value llvm_append_namedmd(LLVMModuleRef M, value Name, LLVMValueRef Val
 
 /* lltype -> int -> llvalue */
 CAMLprim LLVMValueRef llvm_const_int(LLVMTypeRef IntTy, value N) {
 
 /* lltype -> int -> llvalue */
 CAMLprim LLVMValueRef llvm_const_int(LLVMTypeRef IntTy, value N) {
-  return LLVMConstInt(IntTy, (long long) Int_val(N), 1);
+  return LLVMConstInt(IntTy, (long long) Long_val(N), 1);
 }
 
 /* lltype -> Int64.t -> bool -> llvalue */
 }
 
 /* lltype -> Int64.t -> bool -> llvalue */
index ae456cf785c8cf0b44f2252ff0693469ef61b362..d4d0417a80e30e9965fb99cf41923d3011e88dc9 100644 (file)
@@ -1,7 +1,7 @@
 (* RUN: rm -rf %t.builddir
  * RUN: mkdir -p %t.builddir
  * RUN: cp %s %t.builddir
 (* RUN: rm -rf %t.builddir
  * RUN: mkdir -p %t.builddir
  * RUN: cp %s %t.builddir
- * RUN: %ocamlopt -warn-error A unix.cmxa llvm.cmxa llvm_bitwriter.cmxa %t.builddir/bitwriter.ml -o %t
+ * RUN: %ocamlopt -warn-error A-3 unix.cmxa llvm.cmxa llvm_bitwriter.cmxa %t.builddir/bitwriter.ml -o %t
  * RUN: %t %t.bc
  * RUN: llvm-dis < %t.bc
  * XFAIL: vg_leak
  * RUN: %t %t.bc
  * RUN: llvm-dis < %t.bc
  * XFAIL: vg_leak
index f014116ffe8ea0a0c0b00b890b1cc30f4a51cb8f..53e0553b0d599ecc50b3d22768d48b2fa03a3bcf 100644 (file)
@@ -126,6 +126,12 @@ let test_constants () =
   ignore (define_global "const_int_string" c m);
   insist (i32_type = type_of c);
 
   ignore (define_global "const_int_string" c m);
   insist (i32_type = type_of c);
 
+  if Sys.word_size = 64; then begin
+    group "long int";
+    let c = const_int i64_type (1 lsl 61) in
+    insist (c = const_of_int64 i64_type (Int64.of_int (1 lsl 61)) false)
+  end;
+
   (* CHECK: @const_string = global {{.*}}c"cruel\00world"
    *)
   group "string";
   (* CHECK: @const_string = global {{.*}}c"cruel\00world"
    *)
   group "string";