From acdcb3773d085eef413385a1c24ea78f01657bcd Mon Sep 17 00:00:00 2001 From: Peter Zotov Date: Tue, 22 Jul 2014 13:55:20 +0000 Subject: [PATCH 1/1] [OCaml] Don't truncate constants over 32 bits in Llvm.const_int. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@213655 91177308-0d34-0410-b5e6-96231b3b80d8 --- bindings/ocaml/llvm/llvm_ocaml.c | 2 +- test/Bindings/Ocaml/bitwriter.ml | 2 +- test/Bindings/Ocaml/vmcore.ml | 6 ++++++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/bindings/ocaml/llvm/llvm_ocaml.c b/bindings/ocaml/llvm/llvm_ocaml.c index d5ebdcd3e31..2044856ef2d 100644 --- a/bindings/ocaml/llvm/llvm_ocaml.c +++ b/bindings/ocaml/llvm/llvm_ocaml.c @@ -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) { - return LLVMConstInt(IntTy, (long long) Int_val(N), 1); + return LLVMConstInt(IntTy, (long long) Long_val(N), 1); } /* lltype -> Int64.t -> bool -> llvalue */ diff --git a/test/Bindings/Ocaml/bitwriter.ml b/test/Bindings/Ocaml/bitwriter.ml index ae456cf785c..d4d0417a80e 100644 --- a/test/Bindings/Ocaml/bitwriter.ml +++ b/test/Bindings/Ocaml/bitwriter.ml @@ -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 diff --git a/test/Bindings/Ocaml/vmcore.ml b/test/Bindings/Ocaml/vmcore.ml index f014116ffe8..53e0553b0d5 100644 --- a/test/Bindings/Ocaml/vmcore.ml +++ b/test/Bindings/Ocaml/vmcore.ml @@ -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"; -- 2.34.1