[llvm] r213655 - [OCaml] Don't truncate constants over 32 bits in Llvm.const_int.

Peter Zotov whitequark at whitequark.org
Tue Jul 22 06:55:20 PDT 2014


Author: whitequark
Date: Tue Jul 22 08:55:20 2014
New Revision: 213655

URL: http://llvm.org/viewvc/llvm-project?rev=213655&view=rev
Log:
[OCaml] Don't truncate constants over 32 bits in Llvm.const_int.

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

Modified: llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c?rev=213655&r1=213654&r2=213655&view=diff
==============================================================================
--- llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c (original)
+++ llvm/trunk/bindings/ocaml/llvm/llvm_ocaml.c Tue Jul 22 08:55:20 2014
@@ -695,7 +695,7 @@ CAMLprim value llvm_append_namedmd(LLVMM
 
 /* 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 */

Modified: llvm/trunk/test/Bindings/Ocaml/bitwriter.ml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Ocaml/bitwriter.ml?rev=213655&r1=213654&r2=213655&view=diff
==============================================================================
--- llvm/trunk/test/Bindings/Ocaml/bitwriter.ml (original)
+++ llvm/trunk/test/Bindings/Ocaml/bitwriter.ml Tue Jul 22 08:55:20 2014
@@ -1,7 +1,7 @@
 (* 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

Modified: llvm/trunk/test/Bindings/Ocaml/vmcore.ml
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Bindings/Ocaml/vmcore.ml?rev=213655&r1=213654&r2=213655&view=diff
==============================================================================
--- llvm/trunk/test/Bindings/Ocaml/vmcore.ml (original)
+++ llvm/trunk/test/Bindings/Ocaml/vmcore.ml Tue Jul 22 08:55:20 2014
@@ -126,6 +126,12 @@ let test_constants () =
   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";





More information about the llvm-commits mailing list