追記

opt runtime.bc -std-compile-opts runtime.opt.bc として LLVM の opt コマンドでランタイムを最適化したところ、全体で20秒くらい短縮できた。これは嬉しい。runtime.bc 7412 バイト, runtime.opt.bc 2168 バイト。

ついでに lli で実行する際、 -force-interpreter オプションを付けてみた。これは JIT コンパイルをオフにするオプションで、今のような小さいプログラムならJIT 無しのほうが速いと期待。さらに10秒くらい(誤差かもしれないが)速くなった‥が、エラーが1つだけ発生。他のテストは全て通っている。-force-interpreter  オプションの有無のみが影響している。これはまずい。

;; lli で実行; -force-interpreter なし
gosh> (test-e "code+closure funcall" "8\n"
        '(labels ((f-code (code (x) () 8)))
           (let ((f (closure f-code)))
             (funcall f 1))))
test code+closure funcall, expects "8\n" ==> ok

;; lli で実行; -force-interpreter 付き
gosh> (test-e "code+closure funcall" "8\n"
        '(labels ((f-code (code (x) () 8)))
           (let ((f (closure f-code)))
             (funcall f 1))))
Execution.cpp:1322: failed assertion `(ArgVals.size() == F->arg_size() || (ArgVals.size() > F->arg_size() && F->getFunctionType()->isVarArg()))&& "Invalid number of values passed to function invocation!"'
test code+closure funcall, expects "8\n" ==> ERROR: GOT ""

怪しげな LLVM の assert で引っ掛かっている。これはおそらく LLVM の問題ではなく、自分のプログラムが今までたまたま動いていた、という可能性が高い。これは非常によろしくない。万一 LLVM のバグとしてもそれはそれで困る。うーん。