prepare for 5.3.1 merge

pull/81/head
Dibyendu Majumdar 9 years ago
parent b8983e9421
commit f8a17a7b37

@ -2,8 +2,9 @@
extern int printf(const char *, ...);
void testfunc(struct GCObject *obj) { printf("value = %d\n", obj->tt); }
extern int luaD_poscall(struct lua_State *L, struct TValue *ra);
extern int luaD_poscall(struct lua_State *L, struct TValue *ra, int n);
extern void luaF_close(struct lua_State *L, struct TValue *base);
extern void test1(struct lua_State *L, int b);
/*
The following represents a C version of the Lua function:
@ -27,7 +28,7 @@ extern void luaF_close(struct lua_State *L, struct TValue *base);
upvalues (0) for 00000033C3366630:
*/
void test1(struct lua_State *L) {
void test1(struct lua_State *L, int b) {
/* This is the function prologue */
struct CallInfoLua *ci;
@ -52,13 +53,13 @@ void test1(struct lua_State *L) {
*ra2 = *rb2;
/* OP_RETURN instruction */
int b = 3;
struct TValue *ra3 = base + 0;
// if (b)
L->top = ra3 + b - 1;
//L->top = ra3 + b - 1;
if (cl->p->sizep > 0)
luaF_close(L, base);
b = luaD_poscall(L, ra3);
int n = (b != 0) ? b-1 : (int)(L->top - ra);
b = luaD_poscall(L, ra3, n);
if (b)
L->top = ci->top;
}

@ -1,5 +1,5 @@
; ModuleID = 'lua_op_loadk_return.c'
target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-S32"
target triple = "i686-pc-windows-gnu"
%struct.GCObject = type { %struct.GCObject*, i8, i8 }
@ -26,108 +26,236 @@ target triple = "i686-pc-windows-gnu"
@.str = private unnamed_addr constant [12 x i8] c"value = %d\0A\00", align 1
; Function Attrs: nounwind
define void @testfunc(%struct.GCObject* nocapture readonly %obj) #0 {
define void @testfunc(%struct.GCObject* %obj) #0 {
entry:
%tt = getelementptr inbounds %struct.GCObject* %obj, i32 0, i32 1
%0 = load i8* %tt, align 1, !tbaa !1
%conv = zext i8 %0 to i32
%call = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([12 x i8]* @.str, i32 0, i32 0), i32 %conv) #1
%obj.addr = alloca %struct.GCObject*, align 4
store %struct.GCObject* %obj, %struct.GCObject** %obj.addr, align 4, !tbaa !1
%0 = load %struct.GCObject*, %struct.GCObject** %obj.addr, align 4, !tbaa !1
%tt = getelementptr inbounds %struct.GCObject, %struct.GCObject* %0, i32 0, i32 1
%1 = load i8, i8* %tt, align 1, !tbaa !5
%conv = zext i8 %1 to i32
%call = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i32 0, i32 0), i32 %conv)
ret void
}
; Function Attrs: nounwind
declare i32 @printf(i8* nocapture readonly, ...) #0
declare i32 @printf(i8*, ...) #1
; Function Attrs: nounwind
define void @test1(%struct.lua_State* %L) #0 {
define void @test1(%struct.lua_State* %L, i32 %b) #0 {
entry:
%ci1 = getelementptr inbounds %struct.lua_State* %L, i32 0, i32 6
%0 = load %struct.CallInfoLua** %ci1, align 4, !tbaa !6
%base2 = getelementptr inbounds %struct.CallInfoLua* %0, i32 0, i32 4, i32 0
%1 = load %struct.TValue** %base2, align 4, !tbaa !12
%2 = bitcast %struct.CallInfoLua* %0 to %struct.LClosure***
%3 = load %struct.LClosure*** %2, align 4, !tbaa !15
%4 = load %struct.LClosure** %3, align 4, !tbaa !16
%p = getelementptr inbounds %struct.LClosure* %4, i32 0, i32 5
%5 = load %struct.Proto** %p, align 4, !tbaa !17
%k3 = getelementptr inbounds %struct.Proto* %5, i32 0, i32 14
%6 = load %struct.TValue** %k3, align 4, !tbaa !19
%7 = bitcast %struct.TValue* %1 to i8*
%8 = bitcast %struct.TValue* %6 to i8*
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %7, i8* %8, i32 16, i32 8, i1 false), !tbaa.struct !22
%add.ptr5 = getelementptr inbounds %struct.TValue* %1, i32 1
%add.ptr6 = getelementptr inbounds %struct.TValue* %6, i32 1
%9 = bitcast %struct.TValue* %add.ptr5 to i8*
%10 = bitcast %struct.TValue* %add.ptr6 to i8*
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %9, i8* %10, i32 16, i32 8, i1 false), !tbaa.struct !22
%add.ptr9 = getelementptr inbounds %struct.TValue* %1, i32 2
%top = getelementptr inbounds %struct.lua_State* %L, i32 0, i32 4
store %struct.TValue* %add.ptr9, %struct.TValue** %top, align 4, !tbaa !27
%11 = load %struct.Proto** %p, align 4, !tbaa !17
%sizep = getelementptr inbounds %struct.Proto* %11, i32 0, i32 10
%12 = load i32* %sizep, align 4, !tbaa !28
%cmp = icmp sgt i32 %12, 0
%L.addr = alloca %struct.lua_State*, align 4
%b.addr = alloca i32, align 4
%ci = alloca %struct.CallInfoLua*, align 4
%cl = alloca %struct.LClosure*, align 4
%k = alloca %struct.TValue*, align 4
%base = alloca %struct.TValue*, align 4
%cil = alloca %struct.CallInfoL*, align 4
%ra = alloca %struct.TValue*, align 4
%rb = alloca %struct.TValue*, align 4
%ra2 = alloca %struct.TValue*, align 4
%rb2 = alloca %struct.TValue*, align 4
%ra3 = alloca %struct.TValue*, align 4
%n = alloca i32, align 4
store %struct.lua_State* %L, %struct.lua_State** %L.addr, align 4, !tbaa !1
store i32 %b, i32* %b.addr, align 4, !tbaa !7
%0 = bitcast %struct.CallInfoLua** %ci to i8*
call void @llvm.lifetime.start(i64 4, i8* %0) #2
%1 = bitcast %struct.LClosure** %cl to i8*
call void @llvm.lifetime.start(i64 4, i8* %1) #2
%2 = bitcast %struct.TValue** %k to i8*
call void @llvm.lifetime.start(i64 4, i8* %2) #2
%3 = bitcast %struct.TValue** %base to i8*
call void @llvm.lifetime.start(i64 4, i8* %3) #2
%4 = bitcast %struct.CallInfoL** %cil to i8*
call void @llvm.lifetime.start(i64 4, i8* %4) #2
%5 = load %struct.lua_State*, %struct.lua_State** %L.addr, align 4, !tbaa !1
%ci1 = getelementptr inbounds %struct.lua_State, %struct.lua_State* %5, i32 0, i32 6
%6 = load %struct.CallInfoLua*, %struct.CallInfoLua** %ci1, align 4, !tbaa !9
store %struct.CallInfoLua* %6, %struct.CallInfoLua** %ci, align 4, !tbaa !1
%7 = load %struct.CallInfoLua*, %struct.CallInfoLua** %ci, align 4, !tbaa !1
%l = getelementptr inbounds %struct.CallInfoLua, %struct.CallInfoLua* %7, i32 0, i32 4
%base2 = getelementptr inbounds %struct.CallInfoL, %struct.CallInfoL* %l, i32 0, i32 0
%8 = load %struct.TValue*, %struct.TValue** %base2, align 4, !tbaa !14
store %struct.TValue* %8, %struct.TValue** %base, align 4, !tbaa !1
%9 = load %struct.CallInfoLua*, %struct.CallInfoLua** %ci, align 4, !tbaa !1
%func = getelementptr inbounds %struct.CallInfoLua, %struct.CallInfoLua* %9, i32 0, i32 0
%10 = load %struct.TValue*, %struct.TValue** %func, align 4, !tbaa !17
%value_ = getelementptr inbounds %struct.TValue, %struct.TValue* %10, i32 0, i32 0
%gc = bitcast %union.Value* %value_ to %struct.GCObject**
%11 = load %struct.GCObject*, %struct.GCObject** %gc, align 4, !tbaa !1
%12 = bitcast %struct.GCObject* %11 to %struct.LClosure*
store %struct.LClosure* %12, %struct.LClosure** %cl, align 4, !tbaa !1
%13 = load %struct.LClosure*, %struct.LClosure** %cl, align 4, !tbaa !1
%p = getelementptr inbounds %struct.LClosure, %struct.LClosure* %13, i32 0, i32 5
%14 = load %struct.Proto*, %struct.Proto** %p, align 4, !tbaa !18
%k3 = getelementptr inbounds %struct.Proto, %struct.Proto* %14, i32 0, i32 14
%15 = load %struct.TValue*, %struct.TValue** %k3, align 4, !tbaa !20
store %struct.TValue* %15, %struct.TValue** %k, align 4, !tbaa !1
%16 = bitcast %struct.TValue** %ra to i8*
call void @llvm.lifetime.start(i64 4, i8* %16) #2
%17 = load %struct.TValue*, %struct.TValue** %base, align 4, !tbaa !1
%add.ptr = getelementptr inbounds %struct.TValue, %struct.TValue* %17, i32 0
store %struct.TValue* %add.ptr, %struct.TValue** %ra, align 4, !tbaa !1
%18 = bitcast %struct.TValue** %rb to i8*
call void @llvm.lifetime.start(i64 4, i8* %18) #2
%19 = load %struct.TValue*, %struct.TValue** %k, align 4, !tbaa !1
%add.ptr4 = getelementptr inbounds %struct.TValue, %struct.TValue* %19, i32 0
store %struct.TValue* %add.ptr4, %struct.TValue** %rb, align 4, !tbaa !1
%20 = load %struct.TValue*, %struct.TValue** %ra, align 4, !tbaa !1
%21 = load %struct.TValue*, %struct.TValue** %rb, align 4, !tbaa !1
%22 = bitcast %struct.TValue* %20 to i8*
%23 = bitcast %struct.TValue* %21 to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %22, i8* %23, i32 16, i32 8, i1 false), !tbaa.struct !23
%24 = bitcast %struct.TValue** %ra2 to i8*
call void @llvm.lifetime.start(i64 4, i8* %24) #2
%25 = load %struct.TValue*, %struct.TValue** %base, align 4, !tbaa !1
%add.ptr5 = getelementptr inbounds %struct.TValue, %struct.TValue* %25, i32 1
store %struct.TValue* %add.ptr5, %struct.TValue** %ra2, align 4, !tbaa !1
%26 = bitcast %struct.TValue** %rb2 to i8*
call void @llvm.lifetime.start(i64 4, i8* %26) #2
%27 = load %struct.TValue*, %struct.TValue** %k, align 4, !tbaa !1
%add.ptr6 = getelementptr inbounds %struct.TValue, %struct.TValue* %27, i32 1
store %struct.TValue* %add.ptr6, %struct.TValue** %rb2, align 4, !tbaa !1
%28 = load %struct.TValue*, %struct.TValue** %ra2, align 4, !tbaa !1
%29 = load %struct.TValue*, %struct.TValue** %rb2, align 4, !tbaa !1
%30 = bitcast %struct.TValue* %28 to i8*
%31 = bitcast %struct.TValue* %29 to i8*
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %30, i8* %31, i32 16, i32 8, i1 false), !tbaa.struct !23
%32 = bitcast %struct.TValue** %ra3 to i8*
call void @llvm.lifetime.start(i64 4, i8* %32) #2
%33 = load %struct.TValue*, %struct.TValue** %base, align 4, !tbaa !1
%add.ptr7 = getelementptr inbounds %struct.TValue, %struct.TValue* %33, i32 0
store %struct.TValue* %add.ptr7, %struct.TValue** %ra3, align 4, !tbaa !1
%34 = load %struct.LClosure*, %struct.LClosure** %cl, align 4, !tbaa !1
%p8 = getelementptr inbounds %struct.LClosure, %struct.LClosure* %34, i32 0, i32 5
%35 = load %struct.Proto*, %struct.Proto** %p8, align 4, !tbaa !18
%sizep = getelementptr inbounds %struct.Proto, %struct.Proto* %35, i32 0, i32 10
%36 = load i32, i32* %sizep, align 4, !tbaa !27
%cmp = icmp sgt i32 %36, 0
br i1 %cmp, label %if.then, label %if.end
if.then: ; preds = %entry
tail call void @luaF_close(%struct.lua_State* %L, %struct.TValue* %1) #1
%37 = load %struct.lua_State*, %struct.lua_State** %L.addr, align 4, !tbaa !1
%38 = load %struct.TValue*, %struct.TValue** %base, align 4, !tbaa !1
call void @luaF_close(%struct.lua_State* %37, %struct.TValue* %38)
br label %if.end
if.end: ; preds = %if.then, %entry
%call = tail call i32 @luaD_poscall(%struct.lua_State* %L, %struct.TValue* %1) #1
%tobool = icmp eq i32 %call, 0
br i1 %tobool, label %if.end14, label %if.then11
%39 = bitcast i32* %n to i8*
call void @llvm.lifetime.start(i64 4, i8* %39) #2
%40 = load i32, i32* %b.addr, align 4, !tbaa !7
%cmp9 = icmp ne i32 %40, 0
br i1 %cmp9, label %cond.true, label %cond.false
cond.true: ; preds = %if.end
%41 = load i32, i32* %b.addr, align 4, !tbaa !7
%sub = sub nsw i32 %41, 1
br label %cond.end
cond.false: ; preds = %if.end
%42 = load %struct.lua_State*, %struct.lua_State** %L.addr, align 4, !tbaa !1
%top = getelementptr inbounds %struct.lua_State, %struct.lua_State* %42, i32 0, i32 4
%43 = load %struct.TValue*, %struct.TValue** %top, align 4, !tbaa !28
%44 = load %struct.TValue*, %struct.TValue** %ra, align 4, !tbaa !1
%sub.ptr.lhs.cast = ptrtoint %struct.TValue* %43 to i32
%sub.ptr.rhs.cast = ptrtoint %struct.TValue* %44 to i32
%sub.ptr.sub = sub i32 %sub.ptr.lhs.cast, %sub.ptr.rhs.cast
%sub.ptr.div = sdiv exact i32 %sub.ptr.sub, 16
br label %cond.end
cond.end: ; preds = %cond.false, %cond.true
%cond = phi i32 [ %sub, %cond.true ], [ %sub.ptr.div, %cond.false ]
store i32 %cond, i32* %n, align 4, !tbaa !7
%45 = load %struct.lua_State*, %struct.lua_State** %L.addr, align 4, !tbaa !1
%46 = load %struct.TValue*, %struct.TValue** %ra3, align 4, !tbaa !1
%47 = load i32, i32* %n, align 4, !tbaa !7
%call = call i32 @luaD_poscall(%struct.lua_State* %45, %struct.TValue* %46, i32 %47)
store i32 %call, i32* %b.addr, align 4, !tbaa !7
%48 = load i32, i32* %b.addr, align 4, !tbaa !7
%tobool = icmp ne i32 %48, 0
br i1 %tobool, label %if.then10, label %if.end13
if.then11: ; preds = %if.end
%top12 = getelementptr inbounds %struct.CallInfoLua* %0, i32 0, i32 1
%13 = load %struct.TValue** %top12, align 4, !tbaa !29
store %struct.TValue* %13, %struct.TValue** %top, align 4, !tbaa !27
br label %if.end14
if.then10: ; preds = %cond.end
%49 = load %struct.CallInfoLua*, %struct.CallInfoLua** %ci, align 4, !tbaa !1
%top11 = getelementptr inbounds %struct.CallInfoLua, %struct.CallInfoLua* %49, i32 0, i32 1
%50 = load %struct.TValue*, %struct.TValue** %top11, align 4, !tbaa !29
%51 = load %struct.lua_State*, %struct.lua_State** %L.addr, align 4, !tbaa !1
%top12 = getelementptr inbounds %struct.lua_State, %struct.lua_State* %51, i32 0, i32 4
store %struct.TValue* %50, %struct.TValue** %top12, align 4, !tbaa !28
br label %if.end13
if.end14: ; preds = %if.end, %if.then11
if.end13: ; preds = %if.then10, %cond.end
%52 = bitcast i32* %n to i8*
call void @llvm.lifetime.end(i64 4, i8* %52) #2
%53 = bitcast %struct.TValue** %ra3 to i8*
call void @llvm.lifetime.end(i64 4, i8* %53) #2
%54 = bitcast %struct.TValue** %rb2 to i8*
call void @llvm.lifetime.end(i64 4, i8* %54) #2
%55 = bitcast %struct.TValue** %ra2 to i8*
call void @llvm.lifetime.end(i64 4, i8* %55) #2
%56 = bitcast %struct.TValue** %rb to i8*
call void @llvm.lifetime.end(i64 4, i8* %56) #2
%57 = bitcast %struct.TValue** %ra to i8*
call void @llvm.lifetime.end(i64 4, i8* %57) #2
%58 = bitcast %struct.CallInfoL** %cil to i8*
call void @llvm.lifetime.end(i64 4, i8* %58) #2
%59 = bitcast %struct.TValue** %base to i8*
call void @llvm.lifetime.end(i64 4, i8* %59) #2
%60 = bitcast %struct.TValue** %k to i8*
call void @llvm.lifetime.end(i64 4, i8* %60) #2
%61 = bitcast %struct.LClosure** %cl to i8*
call void @llvm.lifetime.end(i64 4, i8* %61) #2
%62 = bitcast %struct.CallInfoLua** %ci to i8*
call void @llvm.lifetime.end(i64 4, i8* %62) #2
ret void
}
; Function Attrs: nounwind
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i32, i1) #1
declare void @llvm.lifetime.start(i64, i8* nocapture) #2
declare void @luaF_close(%struct.lua_State*, %struct.TValue*) #2
; Function Attrs: nounwind
declare void @llvm.memcpy.p0i8.p0i8.i32(i8* nocapture, i8* nocapture readonly, i32, i32, i1) #2
declare void @luaF_close(%struct.lua_State*, %struct.TValue*) #1
declare i32 @luaD_poscall(%struct.lua_State*, %struct.TValue*) #2
declare i32 @luaD_poscall(%struct.lua_State*, %struct.TValue*, i32) #1
; Function Attrs: nounwind
declare void @llvm.lifetime.end(i64, i8* nocapture) #2
attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { nounwind }
attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "no-frame-pointer-elim-non-leaf" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #0 = { nounwind "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #1 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="false" "no-infs-fp-math"="false" "no-nans-fp-math"="false" "no-realign-stack" "stack-protector-buffer-size"="8" "unsafe-fp-math"="false" "use-soft-float"="false" }
attributes #2 = { nounwind }
!llvm.ident = !{!0}
!0 = metadata !{metadata !"clang version 3.6.0 (trunk)"}
!1 = metadata !{metadata !2, metadata !4, i64 4}
!2 = metadata !{metadata !"GCObject", metadata !3, i64 0, metadata !4, i64 4, metadata !4, i64 5}
!3 = metadata !{metadata !"any pointer", metadata !4, i64 0}
!4 = metadata !{metadata !"omnipotent char", metadata !5, i64 0}
!5 = metadata !{metadata !"Simple C/C++ TBAA"}
!6 = metadata !{metadata !7, metadata !3, i64 16}
!7 = metadata !{metadata !"lua_State", metadata !3, i64 0, metadata !4, i64 4, metadata !4, i64 5, metadata !4, i64 6, metadata !3, i64 8, metadata !3, i64 12, metadata !3, i64 16, metadata !3, i64 20, metadata !3, i64 24, metadata !3, i64 28, metadata !3, i64 32, metadata !3, i64 36, metadata !3, i64 40, metadata !3, i64 44, metadata !8, i64 48, metadata !3, i64 104, metadata !9, i64 112, metadata !11, i64 120, metadata !11, i64 124, metadata !11, i64 128, metadata !10, i64 132, metadata !10, i64 134, metadata !4, i64 136, metadata !4, i64 137}
!8 = metadata !{metadata !"CallInfo", metadata !3, i64 0, metadata !3, i64 4, metadata !3, i64 8, metadata !3, i64 12, metadata !4, i64 16, metadata !9, i64 40, metadata !10, i64 48, metadata !4, i64 50, metadata !4, i64 51}
!9 = metadata !{metadata !"long long", metadata !4, i64 0}
!10 = metadata !{metadata !"short", metadata !4, i64 0}
!11 = metadata !{metadata !"int", metadata !4, i64 0}
!12 = metadata !{metadata !13, metadata !3, i64 16}
!13 = metadata !{metadata !"CallInfoLua", metadata !3, i64 0, metadata !3, i64 4, metadata !3, i64 8, metadata !3, i64 12, metadata !14, i64 16, metadata !9, i64 32, metadata !10, i64 40, metadata !4, i64 42, metadata !4, i64 43}
!14 = metadata !{metadata !"CallInfoL", metadata !3, i64 0, metadata !3, i64 4, metadata !9, i64 8}
!15 = metadata !{metadata !13, metadata !3, i64 0}
!16 = metadata !{metadata !3, metadata !3, i64 0}
!17 = metadata !{metadata !18, metadata !3, i64 12}
!18 = metadata !{metadata !"LClosure", metadata !3, i64 0, metadata !4, i64 4, metadata !4, i64 5, metadata !4, i64 6, metadata !3, i64 8, metadata !3, i64 12, metadata !4, i64 16}
!19 = metadata !{metadata !20, metadata !3, i64 44}
!20 = metadata !{metadata !"Proto", metadata !3, i64 0, metadata !4, i64 4, metadata !4, i64 5, metadata !4, i64 6, metadata !4, i64 7, metadata !4, i64 8, metadata !11, i64 12, metadata !11, i64 16, metadata !11, i64 20, metadata !11, i64 24, metadata !11, i64 28, metadata !11, i64 32, metadata !11, i64 36, metadata !11, i64 40, metadata !3, i64 44, metadata !3, i64 48, metadata !3, i64 52, metadata !3, i64 56, metadata !3, i64 60, metadata !3, i64 64, metadata !3, i64 68, metadata !3, i64 72, metadata !3, i64 76, metadata !21, i64 80}
!21 = metadata !{metadata !"RaviJITProto", metadata !4, i64 0, metadata !3, i64 4, metadata !3, i64 8}
!22 = metadata !{i64 0, i64 4, metadata !16, i64 0, i64 4, metadata !16, i64 0, i64 4, metadata !23, i64 0, i64 4, metadata !16, i64 0, i64 8, metadata !24, i64 0, i64 8, metadata !25, i64 8, i64 4, metadata !23}
!23 = metadata !{metadata !11, metadata !11, i64 0}
!24 = metadata !{metadata !9, metadata !9, i64 0}
!25 = metadata !{metadata !26, metadata !26, i64 0}
!26 = metadata !{metadata !"double", metadata !4, i64 0}
!27 = metadata !{metadata !7, metadata !3, i64 8}
!28 = metadata !{metadata !20, metadata !11, i64 28}
!29 = metadata !{metadata !13, metadata !3, i64 4}
!0 = !{!"clang version 3.7.0 (trunk)"}
!1 = !{!2, !2, i64 0}
!2 = !{!"any pointer", !3, i64 0}
!3 = !{!"omnipotent char", !4, i64 0}
!4 = !{!"Simple C/C++ TBAA"}
!5 = !{!6, !3, i64 4}
!6 = !{!"GCObject", !2, i64 0, !3, i64 4, !3, i64 5}
!7 = !{!8, !8, i64 0}
!8 = !{!"int", !3, i64 0}
!9 = !{!10, !2, i64 16}
!10 = !{!"lua_State", !2, i64 0, !3, i64 4, !3, i64 5, !3, i64 6, !2, i64 8, !2, i64 12, !2, i64 16, !2, i64 20, !2, i64 24, !2, i64 28, !2, i64 32, !2, i64 36, !2, i64 40, !2, i64 44, !11, i64 48, !2, i64 104, !12, i64 112, !8, i64 120, !8, i64 124, !8, i64 128, !13, i64 132, !13, i64 134, !3, i64 136, !3, i64 137}
!11 = !{!"CallInfo", !2, i64 0, !2, i64 4, !2, i64 8, !2, i64 12, !3, i64 16, !12, i64 40, !13, i64 48, !3, i64 50, !3, i64 51}
!12 = !{!"long long", !3, i64 0}
!13 = !{!"short", !3, i64 0}
!14 = !{!15, !2, i64 16}
!15 = !{!"CallInfoLua", !2, i64 0, !2, i64 4, !2, i64 8, !2, i64 12, !16, i64 16, !12, i64 32, !13, i64 40, !3, i64 42, !3, i64 43}
!16 = !{!"CallInfoL", !2, i64 0, !2, i64 4, !12, i64 8}
!17 = !{!15, !2, i64 0}
!18 = !{!19, !2, i64 12}
!19 = !{!"LClosure", !2, i64 0, !3, i64 4, !3, i64 5, !3, i64 6, !2, i64 8, !2, i64 12, !3, i64 16}
!20 = !{!21, !2, i64 44}
!21 = !{!"Proto", !2, i64 0, !3, i64 4, !3, i64 5, !3, i64 6, !3, i64 7, !3, i64 8, !8, i64 12, !8, i64 16, !8, i64 20, !8, i64 24, !8, i64 28, !8, i64 32, !8, i64 36, !8, i64 40, !2, i64 44, !2, i64 48, !2, i64 52, !2, i64 56, !2, i64 60, !2, i64 64, !2, i64 68, !2, i64 72, !2, i64 76, !22, i64 80}
!22 = !{!"RaviJITProto", !3, i64 0, !2, i64 4, !2, i64 8}
!23 = !{i64 0, i64 4, !1, i64 0, i64 4, !1, i64 0, i64 4, !7, i64 0, i64 4, !1, i64 0, i64 8, !24, i64 0, i64 8, !25, i64 8, i64 4, !7}
!24 = !{!12, !12, i64 0}
!25 = !{!26, !26, i64 0}
!26 = !{!"double", !3, i64 0}
!27 = !{!21, !8, i64 28}
!28 = !{!10, !2, i64 8}
!29 = !{!15, !2, i64 4}

@ -583,6 +583,8 @@ public:
std::unique_ptr<RaviJITFunctionImpl>
create_function(llvm::IRBuilder<> &builder, RaviFunctionDef *def);
llvm::CallInst *CreateCall1(llvm::IRBuilder<> *builder, llvm::Value *func,
llvm::Value *arg1);
llvm::CallInst *CreateCall2(llvm::IRBuilder<> *builder, llvm::Value *func,
llvm::Value *arg1, llvm::Value *arg2);
llvm::CallInst *CreateCall3(llvm::IRBuilder<> *builder, llvm::Value *func,
@ -668,8 +670,7 @@ public:
llvm::Value *emit_gep_L_top(RaviFunctionDef *def);
// (int)(L->top - ra)
llvm::Value *emit_num_stack_elements(RaviFunctionDef *def, llvm::Value *L_top,
llvm::Value *ra);
llvm::Value *emit_num_stack_elements(RaviFunctionDef *def, llvm::Value *ra);
// Load a register or constant - if constant is int then return a direct LLVM
// constant
@ -764,6 +765,22 @@ public:
// L->top = R(B)
void emit_set_L_top_toreg(RaviFunctionDef *def, int B);
void debug_printf(RaviFunctionDef *def, const char *str);
void debug_printf1(RaviFunctionDef *def, const char *str,
llvm::Value *arg1);
void debug_printf2(RaviFunctionDef *def, const char *str,
llvm::Value *arg1, llvm::Value *arg2);
void debug_printf3(RaviFunctionDef *def, const char *str,
llvm::Value *arg1, llvm::Value *arg2,
llvm::Value *arg3);
void debug_printf4(RaviFunctionDef *def, const char *str,
llvm::Value *arg1, llvm::Value *arg2,
llvm::Value *arg3, llvm::Value *arg4);
// Look for Lua bytecodes that are jump targets and allocate
// a BasicBlock for each such target in def->jump_targets.
// The BasicBlocks are not inserted into the function until later

@ -2,8 +2,8 @@
-- http://benchmarksgame.alioth.debian.org/
-- contributed by Mike Pall
local function fannkuch(n1)
local n:integer = 11
local function fannkuch(n: integer)
--local n:integer = 11
local p: integer[], q :integer[], s: integer[], sign: integer, maxflips: integer, sum: integer = {}, {}, {}, 1, 0, 0
for i=1,n do
p[i] = i
@ -66,7 +66,7 @@ local function fannkuch(n1)
until false
end
local n = tonumber(arg and arg[1]) or 1
local n = tonumber(arg and arg[1]) or 11
assert(ravi.compile(fannkuch))
local t1 = os.clock()
local sum, flips = fannkuch(n)

@ -71,8 +71,7 @@ function matrix.mul(a, b)
end
-- this version avoids using slices - we operate on the
-- one dimensional array; however the version using slices
-- is faster
-- one dimensional array
function matrix.mul2(a, b)
local mrows, mcols, mnew, mdata, mrow, mtran = matrix.rows, matrix.cols, matrix.new, matrix.getdata, matrix.getrow, matrix.T
local m: integer, n: integer, p: integer = mrows(a), mcols(a), mcols(b);
@ -147,7 +146,7 @@ if ravi.jit() then
assert(ravi.compile(matrix.new))
end
local n = arg[1] or 100;
local n = arg[1] or 1000;
n = math.floor(n/2) * 2;
local t1 = os.clock()
local a = matrix.mul2(matrix.gen(n), matrix.gen(n));

@ -1073,6 +1073,7 @@ newframe: /* reentry point when frame changes (call/return) */
DEBUG_STACK(ravi_dump_stack(L, "OP_RETURN: before luaD_poscall()");)
int b = GETARG_B(i);
if (b != 0) L->top = ra + b - 1;
//5.3.1 merge prep if (b == 0) printf("OP_RETURN n = %d\n", (int)(L->top - ra));
if (cl->p->sizep > 0) luaF_close(L, base);
b = luaD_poscall(L, ra);
DEBUG_STACK(ravi_dump_stack(L, "OP_RETURN: after luaD_poscall()");)

@ -39,6 +39,14 @@ const char *RaviCodeGenerator::unique_function_name() {
return temp_;
}
llvm::CallInst *RaviCodeGenerator::CreateCall1(llvm::IRBuilder<> *builder,
llvm::Value *func,
llvm::Value *arg1) {
llvm::SmallVector<llvm::Value *, 1> values;
values.push_back(arg1);
return builder->CreateCall(func, values);
}
llvm::CallInst *RaviCodeGenerator::CreateCall2(llvm::IRBuilder<> *builder,
llvm::Value *func,
llvm::Value *arg1,
@ -605,16 +613,20 @@ llvm::Instruction *RaviCodeGenerator::emit_tofloat(RaviFunctionDef *def,
// (int)(L->top - ra)
llvm::Value *RaviCodeGenerator::emit_num_stack_elements(RaviFunctionDef *def,
llvm::Value *L_top,
llvm::Value *ra) {
llvm::Instruction *top_ptr = def->builder->CreateLoad(L_top, "L_top");
llvm::Value *L_top = emit_gep_L_top(def);
llvm::Instruction *top_ptr = def->builder->CreateLoad(L_top, "L_top_ptr");
llvm::Value *top_asint = def->builder->CreatePtrToInt(
top_ptr, def->types->C_intptr_t, "L_top_as_intptr");
top_ptr, def->types->C_intptr_t, "L_top_ptr_as_int");
llvm::Value *ra_asint =
def->builder->CreatePtrToInt(ra, def->types->C_intptr_t, "ra_as_intptr");
llvm::Value *result =
def->builder->CreateSub(top_asint, ra_asint, "num_stack_elements");
return def->builder->CreateTrunc(result, def->types->C_intT,
def->builder->CreatePtrToInt(ra, def->types->C_intptr_t, "ra_ptr_as_int");
llvm::Value *diff =
def->builder->CreateSub(top_asint, ra_asint, "L_top_minus_ra");
// Because each value object is 16 bytes we need to divide by 16
llvm::Value *n_elements = def->builder->CreateSDiv(
diff, llvm::ConstantInt::get(def->types->C_intptr_t, sizeof(TValue)),
"num_tvalue_elements", true);
return def->builder->CreateTrunc(n_elements, def->types->C_intT,
"num_stack_elements");
}
@ -774,6 +786,37 @@ void RaviCodeGenerator::emit_raise_lua_error(RaviFunctionDef *def,
def->builder->CreateGlobalStringPtr(str));
}
void RaviCodeGenerator::debug_printf(RaviFunctionDef *def, const char *str) {
CreateCall1(def->builder, def->printfFunc,
def->builder->CreateGlobalStringPtr(str));
}
void RaviCodeGenerator::debug_printf1(RaviFunctionDef *def, const char *str,
llvm::Value *arg1) {
CreateCall2(def->builder, def->printfFunc,
def->builder->CreateGlobalStringPtr(str), arg1);
}
void RaviCodeGenerator::debug_printf2(RaviFunctionDef *def, const char *str,
llvm::Value *arg1, llvm::Value *arg2) {
CreateCall3(def->builder, def->printfFunc,
def->builder->CreateGlobalStringPtr(str), arg1, arg2);
}
void RaviCodeGenerator::debug_printf3(RaviFunctionDef *def, const char *str,
llvm::Value *arg1, llvm::Value *arg2,
llvm::Value *arg3) {
CreateCall4(def->builder, def->printfFunc,
def->builder->CreateGlobalStringPtr(str), arg1, arg2, arg3);
}
void RaviCodeGenerator::debug_printf4(RaviFunctionDef *def, const char *str,
llvm::Value *arg1, llvm::Value *arg2,
llvm::Value *arg3, llvm::Value *arg4) {
CreateCall5(def->builder, def->printfFunc,
def->builder->CreateGlobalStringPtr(str), arg1, arg2, arg3, arg4);
}
void RaviCodeGenerator::emit_extern_declarations(RaviFunctionDef *def) {
// Add extern declarations for Lua functions that we need to call

@ -87,6 +87,10 @@ void RaviCodeGenerator::emit_RETURN(RaviFunctionDef *def, int A, int B) {
def->builder->SetInsertPoint(else_block);
//* b = luaD_poscall(L, ra);
// 5.3.1 merge prep
//if (B == 0) {
// debug_printf1(def, "OP_RETURN n = %d\n", emit_num_stack_elements(def, ra_ptr));
//}
CreateCall2(def->builder, def->luaD_poscallF, def->L, ra_ptr);
#if 0

Loading…
Cancel
Save