[llvm-commits] [llvm] r72650 - in /llvm/trunk:include/llvm/CodeGen/JITCodeEmitter.hinclude/llvm/CodeGe n/MachineCodeEmitter.hinclude/llvm/ExecutionEngine/JITMemoryManager. hlib/CodeGen/MachOWriter.cpp lib/CodeGen/MachOWriter.hlib/ExecutionEngi

Julien Lerouge jlerouge at apple.com
Thu Jun 4 15:18:16 PDT 2009


On Thu, Jun 04, 2009 at 02:56:31PM -0700, Julien Lerouge wrote:
> So, in the end, it seems to be coming from 72620. Sorry for the noise.
> I am still working on a test case...
> 

Here is the test case:
$ cat t.c
#include <stdio.h>

int main() {
    return getchar();
}

$ llvm-gcc -c -emit-llvm -o t.bc t.c
$ lli t.bc
Assertion failed: Addr && "Code generation didn't add function to
GlobalAddress table!", file
c:/cygwin/home/jlerouge/buildbot/llvm-test-fixed-src/lib/ExecutionEngine/JIT/JIT.cpp,
line 603

This application has requested the Runtime to terminate it in an unusual
way.
Please contact the application's support team for more information.

The disassembly for the failing bytecode is attached (t.ll).

With 72618, where it's working as expected, the assembly looks like this:

------------------------------
; ModuleID = 't.bc'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
Should I file a PR ?

define i32 @main() nounwind {
entry:
        %retval = alloca i32            ; <i32*> [#uses=2]
        %0 = alloca i32         ; <i32*> [#uses=2]
        %"alloca point" = bitcast i32 0 to i32          ; <i32> [#uses=0]
        %1 = call i32 @getchar() nounwind               ; <i32> [#uses=1]
        store i32 %1, i32* %0, align 4
        %2 = load i32* %0, align 4              ; <i32> [#uses=1]
        store i32 %2, i32* %retval, align 4
        br label %return

return:         ; preds = %entry
        %retval1 = load i32* %retval            ; <i32> [#uses=1]
        ret i32 %retval1
}

declare i32 @getchar() nounwind
------------------------------

Duncan, it seems to be coming from 72619, any idea what's wrong ?

Thanks,
Julien

-- 
Julien Lerouge
PGP Key Id: 0xB1964A62
PGP Fingerprint: 392D 4BAD DB8B CE7F 4E5F FA3C 62DB 4AA7 B196 4A62
PGP Public Key from: keyserver.pgp.com
-------------- next part --------------
; ModuleID = 't.bc'
target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:32:32"
target triple = "i386-pc-mingw32"
	%struct.FILE = type { i8*, i32, i8*, i32, i32, i32, i32, i8* }
@_iob = dllimport global [0 x %struct.FILE]		; <[0 x %struct.FILE]*> [#uses=3]

define i32 @main() nounwind {
entry:
	%retval = alloca i32		; <i32*> [#uses=2]
	%0 = alloca i32		; <i32*> [#uses=2]
	%"alloca point" = bitcast i32 0 to i32		; <i32> [#uses=0]
	%1 = call i32 @getchar() nounwind		; <i32> [#uses=1]
	store i32 %1, i32* %0, align 4
	%2 = load i32* %0, align 4		; <i32> [#uses=1]
	store i32 %2, i32* %retval, align 4
	br label %return

return:		; preds = %entry
	%retval1 = load i32* %retval		; <i32> [#uses=1]
	ret i32 %retval1
}

define available_externally i32 @getchar() nounwind {
entry:
	%retval = alloca i32		; <i32*> [#uses=2]
	%iftmp.2 = alloca i32		; <i32*> [#uses=3]
	%0 = alloca i32		; <i32*> [#uses=2]
	%"alloca point" = bitcast i32 0 to i32		; <i32> [#uses=0]
	%1 = load i32* getelementptr ([0 x %struct.FILE]* @_iob, i32 0, i32 0, i32 1), align 4		; <i32> [#uses=1]
	%2 = sub i32 %1, 1		; <i32> [#uses=1]
	store i32 %2, i32* getelementptr ([0 x %struct.FILE]* @_iob, i32 0, i32 0, i32 1), align 4
	%3 = load i32* getelementptr ([0 x %struct.FILE]* @_iob, i32 0, i32 0, i32 1), align 4		; <i32> [#uses=1]
	%4 = icmp sge i32 %3, 0		; <i1> [#uses=1]
	br i1 %4, label %bb, label %bb1

bb:		; preds = %entry
	%5 = load i8** getelementptr ([0 x %struct.FILE]* @_iob, i32 0, i32 0, i32 0), align 4		; <i8*> [#uses=2]
	%6 = load i8* %5, align 1		; <i8> [#uses=1]
	%7 = zext i8 %6 to i32		; <i32> [#uses=1]
	store i32 %7, i32* %iftmp.2, align 4
	%8 = getelementptr i8* %5, i64 1		; <i8*> [#uses=1]
	store i8* %8, i8** getelementptr ([0 x %struct.FILE]* @_iob, i32 0, i32 0, i32 0), align 4
	br label %bb2

bb1:		; preds = %entry
	%9 = call i32 @_filbuf(%struct.FILE* getelementptr ([0 x %struct.FILE]* @_iob, i32 0, i32 0)) nounwind		; <i32> [#uses=1]
	store i32 %9, i32* %iftmp.2, align 4
	br label %bb2

bb2:		; preds = %bb1, %bb
	%10 = load i32* %iftmp.2, align 4		; <i32> [#uses=1]
	store i32 %10, i32* %0, align 4
	%11 = load i32* %0, align 4		; <i32> [#uses=1]
	store i32 %11, i32* %retval, align 4
	br label %return

return:		; preds = %bb2
	%retval3 = load i32* %retval		; <i32> [#uses=1]
	ret i32 %retval3
}

declare i32 @_filbuf(%struct.FILE*) nounwind


More information about the llvm-commits mailing list