我尝试使用无类型语言生成代码框和取消框值。为了评估一个简单的整数文字3,我生成:
define i64 @0() {
entry:
%value = alloca { i64, [10 x i8], <10 x i64> }
%boxptr = getelementptr inbounds { i64, [10 x i8], <10 x i64> }* %value, i32 0, i32 0
store i64 3, i64* %boxptr
%boxptr1 = getelementptr inbounds { i64, [10 x i8], <10 x i64> }* %value, i32 0, i32 0
%load = load i64* %boxptr1
ret i64 %load
}
看起来正确,lli
将其评估为3,但Llvm_executionengine将函数计算为216172782113783808(垃圾值)。我toplevel.ml
的代码如下:
open Llvm_executionengine
let the_execution_engine = ExecutionEngine.create_interpreter the_module
let print_and_jit se =
let f = sexpr_matcher se in
let result = ExecutionEngine.run_function f [||] the_execution_engine in
print_string "Evaluated to ";
print_int (GenericValue.as_int result);
我的翻译有什么问题?