Open Quuxplusone opened 12 years ago
Attached bug.c
(3048 bytes, application/octet-stream): source code, generates bug
I've found the problem - JIT generates code for x86_64 while the program is in x86 mode.
However, llvm-c ignores the module Triple. Note that the code attached doesn't specify a Triple, but the crash remains when the correct Triple is specified.
I have a patch, and I'll send it to llvm-commits.
I reopened this. Let's close it when the patch goes in, because we need to note the revision in which this bug is fixed.
bug.c
(3048 bytes, application/octet-stream)Created attachment 9201 source code, generates bug
JIT generates code with wrong instructions (which are 0 bytes). These crash (Bus error) when evaluated.
IR: ; ModuleID = 'make_func_module'
define i64 @make_function(i32, i32, i32, i32) { entry: %val = call i64 @void_function() ret i64 %val }
declare i64 @void_function()
ASM: 0x01200030: push %eax 0x01200031: dec %eax 0x01200032: mov $0x10d50,%eax 0x01200037: add %al,(%eax) ## crash 0x01200039: add %al,(%eax) 0x0120003b: call *%eax 0x0120003d: pop %edx 0x0120003e: ret
Source attached. Execution:
/usr/bin/g++
llvm-config --cxxflags
-g -m32 -c bug.c /usr/bin/g++llvm-config --ldflags
-g -m32 -o bug bug.ollvm-config --libs all
./bug