Hello,
I started off trying to test HLVM
(http://www.ffconsultancy.com/ocaml/hlvm/) in a freshly compiled
LLVM3.0,
and found a few errors have crept into LLVM between revisions 2.7 and 2.8.
System info:
2.6.31-23-generic #75-Ubuntu SMP x86_64 GNU/Linux, oprofile version
0.9.3-1.1ubuntu2_amd64
HLVM uses the following code to set "guaranteed" tail call optimization:
<code>
#include "llvm/ADT/StringRef.h" <!-- had to be added, since
TargetOptions references it - as noted already in the list. -->
#include "llvm/Target/TargetOptions.h"
#include <iostream>
extern "C" {
using namespace std;
void enable_tail_call_opt() {
cout << "Enabling TCO" << endl;
//llvm::PerformTailCallOpt = true; <-- pre-2.7 name
llvm::GuaranteedTailCallOpt = true;
}
}
</code>
Compiling 3.0 (but not 2.8 or earlier) I also had to run:
touch llvm-3.0.src/bindings/ocaml/llvm/Release/META.llvm
to passify make install, since it tried to install metadata, but
didn't have any.
Trouble was that just about all test cases would cause "Stack
overflow" during jit execution -
making me suspect a problem with tail call optimization in LLVM.
Stack overflows didn't happen immediately in 3.0, but happened almost
immediately in 2.8.
Sure enough, reverting to LLVM2.7 fixed the issue and no overflow was observed.
A more informed failure case for tail call optimization
was posted a year ago, but never answered. I think correctness of the
3.0 and current
implementations of "GuaranteedTailCallOpt" requires re-examination.
~ Dr. David M. Rogers
Nanobiology Department
Sandia National Labs