[LLVMdev] Possible miscompilation?
Gary Benson
gbenson at redhat.com
Wed Jun 11 08:38:26 PDT 2008
Hi all,
I'm trying to figure out a weird bug I'm seeing. I'm hoping it's
something simple in my IR but I can't see anything wrong so I'm
hoping someone here can see something.
I'm using LLVM to compile Java bytecode into native functions.
My code keeps track of the Java local variables in an array of
llvm::Value pointers which get phi'd up at various points. The
function I'm seeing the bug in has a variable "sl" which is
calculated once and used as a loop end condition, ie:
int sp = 0;
int sl = whatever;
while (sp < sl) {
// do stuff
}
The bug is that in my JITted code, sl is calculated as 57, but
after the first iteration it is 0xf900000 despite nothing touching
it as far as I can see.
I attached a copy of the IR, both for the entire function and
for that section with only the blocks that are actually entered
as the function executes. grepping it for local_5 I don't see
anything that would modify it. There is some tracing code too,
the calls to @trace_bytecode and @print_value; the output from
that is also attached.
The bizarre thing is that if I add print the value of local_5
at every bytecode then everything is correct. This is what is
making me suspect a miscompilation.
Thanks in advance for any help!
Cheers,
Gary
--
http://gbenson.net/
More information about the llvm-dev
mailing list