pull/81/head
Dibyendu Majumdar 9 years ago
parent 29f7c22f9c
commit d82bf96f16

@ -1,271 +1,4 @@
extern int printf(const char *, ...);
struct GCObject {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
};
struct lua_State;
union Value {
struct GCObject *gc;
void *p;
int b;
int (*f)(struct lua_State *);
long long i;
double n;
};
struct TValue {
union Value value_;
int tt_;
};
struct TString {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char extra;
unsigned int hash;
unsigned long long len;
struct TString *hnext;
};
union MaxAlign {
double u;
void *s;
long long i;
long l;
};
union UTString {
union MaxAlign dummy;
struct TString tsv;
};
struct Udata {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char ttuv_; /* user value's tag */
struct Table *metatable;
unsigned long long len; /* number of bytes */
union Value user_; /* user value */
};
union UUdata {
union MaxAlign dummy; /* ensures maximum alignment for 'local' udata */
struct Udata uv;
};
struct Upvaldesc {
struct TString *name; /* upvalue name (for debug information) */
unsigned char instack; /* whether it is in stack */
unsigned char
idx; /* index of upvalue (in stack or in outer function's list) */
};
enum ravitype_t {
RAVI_TANY, /* Lua dynamic type */
RAVI_TNUMINT, /* integer number */
RAVI_TNUMFLT, /* floating point number */
RAVI_TARRAYINT, /* array of ints */
RAVI_TARRAYFLT, /* array of doubles */
RAVI_TFUNCTION,
RAVI_TTABLE,
RAVI_TSTRING,
RAVI_TNIL,
RAVI_TBOOLEAN
};
struct LocVar {
struct TString *varname;
int startpc; /* first point where variable is active */
int endpc; /* first point where variable is dead */
enum ravitype_t
ravi_type; /* RAVI type of the variable - RAVI_TANY if unknown */
};
struct Proto {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char numparams; /* number of fixed parameters */
unsigned char is_vararg;
unsigned char maxstacksize; /* maximum stack used by this function */
int sizeupvalues; /* size of 'upvalues' */
int sizek; /* size of 'k' */
int sizecode;
int sizelineinfo;
int sizep; /* size of 'p' */
int sizelocvars;
int linedefined;
int lastlinedefined;
struct TValue *k; /* constants used by the function */
unsigned int *code;
struct Proto **p; /* functions defined inside the function */
int *lineinfo; /* map from opcodes to source lines (debug information) */
struct LocVar *
locvars; /* information about local variables (debug information) */
struct Upvaldesc *upvalues; /* upvalue information */
struct LClosure *cache; /* last created closure with this prototype */
struct TString *source; /* used for debug information */
struct GCObject *gclist;
} Proto;
struct UpVal;
struct CClosure {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char nupvalues;
struct GCObject *gclist;
int (*f)(struct lua_State *);
struct TValue upvalue[1]; /* list of upvalues */
};
struct LClosure {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char nupvalues;
struct GCObject *gclist;
struct Proto *p;
struct UpVal *upvals[1]; /* list of upvalues */
};
union Closure {
struct CClosure c;
struct LClosure l;
};
union TKey {
struct {
union Value value_;
int tt_;
int next; /* for chaining (offset for next node) */
} nk;
struct TValue tvk;
};
struct Node {
struct TValue i_val;
union TKey i_key;
};
struct Table {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char flags; /* 1<<p means tagmethod(p) is not present */
unsigned char lsizenode; /* log2 of size of 'node' array */
unsigned int sizearray; /* size of 'array' array */
struct TValue *array; /* array part */
struct Node *node;
struct Node *lastfree; /* any free position is before this position */
struct Table *metatable;
struct GCObject *gclist;
char *ravi_data;
enum ravitype_t ravi_array_type; /* RAVI specialization */
unsigned int ravi_array_len; /* RAVI len specialization */
unsigned int ravi_array_size; /* RAVI len specialization */
};
struct Mbuffer {
char *buffer;
unsigned long long n;
unsigned long long buffsize;
};
struct stringtable {
struct TString **hash;
int nuse; /* number of elements */
int size;
};
struct lua_Debug;
typedef long long ptrdiff_t;
typedef ptrdiff_t lua_KContext;
typedef int (*lua_KFunction)(struct lua_State *L, int status, lua_KContext ctx);
typedef void *(*lua_Alloc)(void *ud, void *ptr, unsigned long long osize,
unsigned long long nsize);
typedef void (*lua_Hook)(struct lua_State *L, struct lua_Debug *ar);
struct CallInfoL { /* only for Lua functions */
struct TValue *base; /* base for this function */
const unsigned int *savedpc;
ptrdiff_t dummy;
};
struct CallInfoC { /* only for C functions */
lua_KFunction k; /* continuation in case of yields */
ptrdiff_t old_errfunc;
lua_KContext ctx; /* context info. in case of yields */
};
struct CallInfo {
struct TValue *func; /* function index in the stack */
struct TValue *top; /* top for this function */
struct CallInfo *previous, *next; /* dynamic call link */
union {
struct CallInfoL l;
struct CallInfoC c;
} u;
ptrdiff_t extra;
short nresults; /* expected number of results from this function */
unsigned char callstatus;
unsigned char jitstatus;
};
struct CallInfoLua {
struct TValue *func; /* function index in the stack */
struct TValue *top; /* top for this function */
struct CallInfo *previous, *next; /* dynamic call link */
struct CallInfoL l;
ptrdiff_t extra;
short nresults; /* expected number of results from this function */
unsigned char callstatus;
unsigned char jitstatus;
};
struct global_State;
struct lua_longjmp;
/*
** 'per thread' state
*/
struct lua_State {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char status;
struct TValue *top; /* first free slot in the stack */
struct global_State *l_G;
struct CallInfoLua *ci; /* call info for current function */
const unsigned int *oldpc; /* last pc traced */
struct TValue *stack_last; /* last free slot in the stack */
struct TValue *stack; /* stack base */
struct UpVal *openupval; /* list of open upvalues in this stack */
struct GCObject *gclist;
struct lua_State *twups; /* list of threads with open upvalues */
struct lua_longjmp *errorJmp; /* current error recover point */
struct CallInfo base_ci; /* CallInfo for first level (C calling Lua) */
lua_Hook hook;
ptrdiff_t errfunc; /* current error handling function (stack index) */
int stacksize;
int basehookcount;
int hookcount;
unsigned short nny; /* number of non-yieldable calls in stack */
unsigned short nCcalls; /* number of nested C calls */
unsigned char hookmask;
unsigned char allowhook;
};
void testfunc(struct GCObject *obj) { printf("value = %d\n", obj->tt); }
extern int luaD_poscall(struct lua_State *L, struct TValue *ra);
#include "lua_hdr.h"
/*
The following represents a C version of the Lua function:
@ -304,6 +37,9 @@ extern int luaD_poscall(struct lua_State *L, struct TValue *ra);
upvalues (0) for 00000014E5C8E380:
*/
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 forlimit(const struct TValue *obj, long long int *p, long long int step,
int *stopnow);
extern int luaV_tonumber_(const struct TValue *obj, double *n);

@ -2,30 +2,31 @@
target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"
target triple = "i686-pc-windows-gnu"
%struct.Proto = type { %struct.GCObject*, i8, i8, i8, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, %struct.TValue*, i32*, %struct.Proto**, i32*, %struct.LocVar*, %struct.Upvaldesc*, %struct.LClosure*, %struct.TString*, %struct.GCObject* }
%struct.TValue = type { %union.Value, i32 }
%union.Value = type { i64 }
%struct.LocVar = type { %struct.TString*, i32, i32, i32 }
%struct.Upvaldesc = type { %struct.TString*, i8, i8 }
%struct.LClosure = type { %struct.GCObject*, i8, i8, i8, %struct.GCObject*, %struct.Proto*, [1 x %struct.UpVal*] }
%struct.UpVal = type opaque
%struct.TString = type { %struct.GCObject*, i8, i8, i8, i32, i64, %struct.TString* }
%struct.GCObject = type { %struct.GCObject*, i8, i8 }
%struct.lua_State = type { %struct.GCObject*, i8, i8, i8, %struct.TValue*, %struct.global_State*, %struct.CallInfoLua*, i32*, %struct.TValue*, %struct.TValue*, %struct.UpVal*, %struct.GCObject*, %struct.lua_State*, %struct.lua_longjmp*, %struct.CallInfo, void (%struct.lua_State*, %struct.lua_Debug*)*, i64, i32, i32, i32, i16, i16, i8, i8 }
%struct.global_State = type opaque
%struct.CallInfoLua = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %struct.CallInfoL, i64, i16, i8 }
%struct.CallInfoLua = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %struct.CallInfoL, i64, i16, i8, i8 }
%struct.CallInfoL = type { %struct.TValue*, i32*, i64 }
%struct.TValue = type { %union.Value, i32 }
%union.Value = type { i64 }
%struct.UpVal = type { %struct.TValue*, i64, %union.anon.0 }
%union.anon.0 = type { %struct.TValue }
%struct.lua_longjmp = type opaque
%struct.CallInfo = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %union.anon, i64, i16, i8 }
%struct.CallInfo = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %union.anon, i64, i16, i8, i8 }
%union.anon = type { %struct.CallInfoC }
%struct.CallInfoC = type { i32 (%struct.lua_State*, i32, i64)*, i64, i64 }
%struct.lua_Debug = type opaque
%struct.LClosure = type { %struct.GCObject*, i8, i8, i8, %struct.GCObject*, %struct.Proto*, [1 x %struct.UpVal*] }
%struct.Proto = type { %struct.GCObject*, i8, i8, i8, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, %struct.TValue*, i32*, %struct.Proto**, i32*, %struct.LocVar*, %struct.Upvaldesc*, %struct.LClosure*, %struct.TString*, %struct.GCObject*, %struct.RaviJITProto }
%struct.LocVar = type { %struct.TString*, i32, i32, i32 }
%struct.Upvaldesc = type { %struct.TString*, i32, i8, i8 }
%struct.TString = type { %struct.GCObject*, i8, i8, i8, i32, i64, %struct.TString* }
%struct.RaviJITProto = type { i8, i8*, i32 (%struct.lua_State*)* }
@.str = private unnamed_addr constant [12 x i8] c"value = %d\0A\00", align 1
@.str1 = private unnamed_addr constant [29 x i8] c"'for' limit must be a number\00", align 1
@.str2 = private unnamed_addr constant [28 x i8] c"'for' step must be a number\00", align 1
@.str3 = private unnamed_addr constant [37 x i8] c"'for' initial value must be a number\00", align 1
@Proto = common global %struct.Proto zeroinitializer, align 4
; Function Attrs: nounwind
define void @testfunc(%struct.GCObject* nocapture readonly %obj) #0 {
@ -61,28 +62,28 @@ entry:
%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 !21
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 !21
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %9, i8* %10, i32 16, i32 8, i1 false), !tbaa.struct !22
%add.ptr7 = getelementptr inbounds %struct.TValue* %1, i32 2
%add.ptr8 = getelementptr inbounds %struct.TValue* %6, i32 2
%11 = bitcast %struct.TValue* %add.ptr7 to i8*
%12 = bitcast %struct.TValue* %add.ptr8 to i8*
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %11, i8* %12, i32 16, i32 8, i1 false), !tbaa.struct !21
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %11, i8* %12, i32 16, i32 8, i1 false), !tbaa.struct !22
%add.ptr9 = getelementptr inbounds %struct.TValue* %1, i32 3
%13 = bitcast %struct.TValue* %add.ptr9 to i8*
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %13, i8* %10, i32 16, i32 8, i1 false), !tbaa.struct !21
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %13, i8* %10, i32 16, i32 8, i1 false), !tbaa.struct !22
%tt_ = getelementptr inbounds %struct.TValue* %1, i32 1, i32 1
%14 = load i32* %tt_, align 4, !tbaa !26
%14 = load i32* %tt_, align 4, !tbaa !27
%cmp = icmp eq i32 %14, 19
%tt_14 = getelementptr inbounds %struct.TValue* %1, i32 3, i32 1
%15 = load i32* %tt_14, align 4, !tbaa !26
%15 = load i32* %tt_14, align 4, !tbaa !27
%cmp15 = icmp eq i32 %15, 19
%i = getelementptr inbounds %struct.TValue* %add.ptr9, i32 0, i32 0, i32 0
%16 = load i64* %i, align 8, !tbaa !23
%16 = load i64* %i, align 8, !tbaa !24
%call = call i32 @forlimit(%struct.TValue* %add.ptr7, i64* %ilimit, i64 %16, i32* %stopnow) #1
%or.cond = and i1 %cmp, %cmp15
%tobool20 = icmp ne i32 %call, 0
@ -90,25 +91,25 @@ entry:
br i1 %or.cond158, label %if.then, label %if.else
if.then: ; preds = %entry
%17 = load i32* %stopnow, align 4, !tbaa !22
%17 = load i32* %stopnow, align 4, !tbaa !23
%tobool21 = icmp eq i32 %17, 0
%i23 = getelementptr inbounds %struct.TValue* %add.ptr5, i32 0, i32 0, i32 0
br i1 %tobool21, label %cond.false, label %cond.end
cond.false: ; preds = %if.then
%18 = load i64* %i23, align 8, !tbaa !23
%18 = load i64* %i23, align 8, !tbaa !24
br label %cond.end
cond.end: ; preds = %if.then, %cond.false
%cond = phi i64 [ %18, %cond.false ], [ 0, %if.then ]
%19 = load i64* %ilimit, align 8, !tbaa !23
%19 = load i64* %ilimit, align 8, !tbaa !24
%i25 = getelementptr inbounds %struct.TValue* %add.ptr7, i32 0, i32 0, i32 0
store i64 %19, i64* %i25, align 8, !tbaa !23
store i64 %19, i64* %i25, align 8, !tbaa !24
%tt_26 = getelementptr inbounds %struct.TValue* %1, i32 2, i32 1
store i32 19, i32* %tt_26, align 4, !tbaa !26
%20 = load i64* %i, align 8, !tbaa !23
store i32 19, i32* %tt_26, align 4, !tbaa !27
%20 = load i64* %i, align 8, !tbaa !24
%sub = sub nsw i64 %cond, %20
store i64 %sub, i64* %i23, align 8, !tbaa !23
store i64 %sub, i64* %i23, align 8, !tbaa !24
%21 = bitcast i64 %sub to double
%n116.pre = bitcast %struct.TValue* %add.ptr9 to double*
%n119.pre = bitcast %struct.TValue* %add.ptr5 to double*
@ -117,14 +118,14 @@ cond.end: ; preds = %if.then, %cond.fals
if.else: ; preds = %entry
%tt_32 = getelementptr inbounds %struct.TValue* %1, i32 2, i32 1
%22 = load i32* %tt_32, align 4, !tbaa !26
%22 = load i32* %tt_32, align 4, !tbaa !27
%cmp33 = icmp eq i32 %22, 3
br i1 %cmp33, label %if.then35, label %if.else37
if.then35: ; preds = %if.else
%n = bitcast %struct.TValue* %add.ptr7 to double*
%23 = load double* %n, align 8, !tbaa !24
store double %23, double* %nlimit, align 8, !tbaa !24
%23 = load double* %n, align 8, !tbaa !25
store double %23, double* %nlimit, align 8, !tbaa !25
br label %if.end42
if.else37: ; preds = %if.else
@ -137,18 +138,18 @@ if.then40: ; preds = %if.else37
br label %if.end42
if.end42: ; preds = %if.else37, %if.then35, %if.then40
%24 = load double* %nlimit, align 8, !tbaa !24
%24 = load double* %nlimit, align 8, !tbaa !25
%n44 = bitcast %struct.TValue* %add.ptr7 to double*
store double %24, double* %n44, align 8, !tbaa !24
store i32 3, i32* %tt_32, align 4, !tbaa !26
%25 = load i32* %tt_14, align 4, !tbaa !26
store double %24, double* %n44, align 8, !tbaa !25
store i32 3, i32* %tt_32, align 4, !tbaa !27
%25 = load i32* %tt_14, align 4, !tbaa !27
%cmp47 = icmp eq i32 %25, 3
br i1 %cmp47, label %if.then49, label %if.else52
if.then49: ; preds = %if.end42
%n51 = bitcast %struct.TValue* %add.ptr9 to double*
%26 = load double* %n51, align 8, !tbaa !24
store double %26, double* %nstep, align 8, !tbaa !24
%26 = load double* %n51, align 8, !tbaa !25
store double %26, double* %nstep, align 8, !tbaa !25
br label %if.end58
if.else52: ; preds = %if.end42
@ -161,18 +162,18 @@ if.then56: ; preds = %if.else52
br label %if.end58
if.end58: ; preds = %if.else52, %if.then49, %if.then56
%27 = load double* %nstep, align 8, !tbaa !24
%27 = load double* %nstep, align 8, !tbaa !25
%n60 = bitcast %struct.TValue* %add.ptr9 to double*
store double %27, double* %n60, align 8, !tbaa !24
store i32 3, i32* %tt_14, align 4, !tbaa !26
%28 = load i32* %tt_, align 4, !tbaa !26
store double %27, double* %n60, align 8, !tbaa !25
store i32 3, i32* %tt_14, align 4, !tbaa !27
%28 = load i32* %tt_, align 4, !tbaa !27
%cmp63 = icmp eq i32 %28, 3
br i1 %cmp63, label %if.then65, label %if.else68
if.then65: ; preds = %if.end58
%n67 = bitcast %struct.TValue* %add.ptr5 to double*
%29 = load double* %n67, align 8, !tbaa !24
store double %29, double* %ninit, align 8, !tbaa !24
%29 = load double* %n67, align 8, !tbaa !25
store double %29, double* %ninit, align 8, !tbaa !25
br label %if.end74
if.else68: ; preds = %if.end58
@ -185,11 +186,11 @@ if.then72: ; preds = %if.else68
br label %if.end74
if.end74: ; preds = %if.else68, %if.then65, %if.then72
%30 = load double* %ninit, align 8, !tbaa !24
%31 = load double* %nstep, align 8, !tbaa !24
%30 = load double* %ninit, align 8, !tbaa !25
%31 = load double* %nstep, align 8, !tbaa !25
%sub75 = fsub double %30, %31
%n77 = bitcast %struct.TValue* %add.ptr5 to double*
store double %sub75, double* %n77, align 8, !tbaa !24
store double %sub75, double* %n77, align 8, !tbaa !25
%32 = bitcast double %sub75 to i64
%i91.pre = getelementptr inbounds %struct.TValue* %add.ptr5, i32 0, i32 0, i32 0
%i94.pre = getelementptr inbounds %struct.TValue* %add.ptr7, i32 0, i32 0, i32 0
@ -204,7 +205,7 @@ label_forloop.preheader: ; preds = %if.end74, %cond.end
%33 = phi double [ %sub75, %if.end74 ], [ %21, %cond.end ]
%34 = phi i64 [ %32, %if.end74 ], [ %sub, %cond.end ]
%storemerge = phi i32 [ 3, %if.end74 ], [ 19, %cond.end ]
store i32 %storemerge, i32* %tt_, align 4, !tbaa !26
store i32 %storemerge, i32* %tt_, align 4, !tbaa !27
%i109 = getelementptr inbounds %struct.TValue* %1, i32 4, i32 0, i32 0
%tt_110 = getelementptr inbounds %struct.TValue* %1, i32 4, i32 1
%add.ptr81 = getelementptr inbounds %struct.TValue* %1, i32 4
@ -216,7 +217,7 @@ label_loopbody: ; preds = %if.then133, %if.the
%36 = phi double [ %add120, %if.then133 ], [ %43, %if.then103 ]
%.pr = phi i32 [ 3, %if.then133 ], [ 19, %if.then103 ]
%37 = phi i64 [ %46, %if.then133 ], [ %add, %if.then103 ]
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %7, i8* %35, i32 16, i32 8, i1 false), !tbaa.struct !21
call void @llvm.memcpy.p0i8.p0i8.i32(i8* %7, i8* %35, i32 16, i32 8, i1 false), !tbaa.struct !22
br label %label_forloop
label_forloop: ; preds = %label_forloop.preheader, %label_loopbody
@ -227,9 +228,9 @@ label_forloop: ; preds = %label_forloop.prehe
br i1 %cmp84, label %if.then86, label %if.else112
if.then86: ; preds = %label_forloop
%41 = load i64* %i, align 8, !tbaa !23
%41 = load i64* %i, align 8, !tbaa !24
%add = add nsw i64 %39, %41
%42 = load i64* %i94.pre-phi, align 8, !tbaa !23
%42 = load i64* %i94.pre-phi, align 8, !tbaa !24
%cmp95 = icmp sgt i64 %41, 0
br i1 %cmp95, label %cond.true97, label %cond.false100
@ -242,17 +243,17 @@ cond.false100: ; preds = %if.then86
br i1 %cmp101, label %if.end142, label %if.then103
if.then103: ; preds = %cond.true97, %cond.false100
store i64 %add, i64* %i91.pre-phi, align 8, !tbaa !23
store i32 19, i32* %tt_, align 4, !tbaa !26
store i64 %add, i64* %i109, align 8, !tbaa !23
store i32 19, i32* %tt_110, align 4, !tbaa !26
store i64 %add, i64* %i91.pre-phi, align 8, !tbaa !24
store i32 19, i32* %tt_, align 4, !tbaa !27
store i64 %add, i64* %i109, align 8, !tbaa !24
store i32 19, i32* %tt_110, align 4, !tbaa !27
%43 = bitcast i64 %add to double
br label %label_loopbody
if.else112: ; preds = %label_forloop
%44 = load double* %n116.pre-phi, align 8, !tbaa !24
%44 = load double* %n116.pre-phi, align 8, !tbaa !25
%add120 = fadd double %44, %38
%45 = load double* %n124.pre-phi, align 8, !tbaa !24
%45 = load double* %n124.pre-phi, align 8, !tbaa !25
%cmp125 = fcmp ogt double %44, 0.000000e+00
br i1 %cmp125, label %cond.true127, label %cond.false130
@ -265,19 +266,19 @@ cond.false130: ; preds = %if.else112
br i1 %cmp131, label %if.end142, label %if.then133
if.then133: ; preds = %cond.true127, %cond.false130
store double %add120, double* %n119.pre-phi, align 8, !tbaa !24
store i32 3, i32* %tt_, align 4, !tbaa !26
store double %add120, double* %n139, align 8, !tbaa !24
store i32 3, i32* %tt_110, align 4, !tbaa !26
store double %add120, double* %n119.pre-phi, align 8, !tbaa !25
store i32 3, i32* %tt_, align 4, !tbaa !27
store double %add120, double* %n139, align 8, !tbaa !25
store i32 3, i32* %tt_110, align 4, !tbaa !27
%46 = bitcast double %add120 to i64
br label %label_loopbody
if.end142: ; preds = %cond.true97, %cond.false100, %cond.true127, %cond.false130
%top = getelementptr inbounds %struct.lua_State* %L, i32 0, i32 4
store %struct.TValue* %add.ptr5, %struct.TValue** %top, align 4, !tbaa !28
store %struct.TValue* %add.ptr5, %struct.TValue** %top, align 4, !tbaa !29
%47 = load %struct.Proto** %p, align 4, !tbaa !17
%sizep = getelementptr inbounds %struct.Proto* %47, i32 0, i32 10
%48 = load i32* %sizep, align 4, !tbaa !29
%48 = load i32* %sizep, align 4, !tbaa !30
%cmp147 = icmp sgt i32 %48, 0
br i1 %cmp147, label %if.then149, label %if.end151
@ -292,8 +293,8 @@ if.end151: ; preds = %if.then149, %if.end
if.then154: ; preds = %if.end151
%top155 = getelementptr inbounds %struct.CallInfoLua* %0, i32 0, i32 1
%49 = load %struct.TValue** %top155, align 4, !tbaa !30
store %struct.TValue* %49, %struct.TValue** %top, align 4, !tbaa !28
%49 = load %struct.TValue** %top155, align 4, !tbaa !31
store %struct.TValue* %49, %struct.TValue** %top, align 4, !tbaa !29
br label %if.end157
if.end157: ; preds = %if.end151, %if.then154
@ -327,26 +328,27 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
!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}
!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}
!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}
!21 = metadata !{i64 0, i64 4, metadata !16, i64 0, i64 4, metadata !16, i64 0, i64 4, metadata !22, i64 0, i64 4, metadata !16, i64 0, i64 8, metadata !23, i64 0, i64 8, metadata !24, i64 8, i64 4, metadata !22}
!22 = metadata !{metadata !11, metadata !11, i64 0}
!23 = metadata !{metadata !9, metadata !9, i64 0}
!24 = metadata !{metadata !25, metadata !25, i64 0}
!25 = metadata !{metadata !"double", metadata !4, i64 0}
!26 = metadata !{metadata !27, metadata !11, i64 8}
!27 = metadata !{metadata !"TValue", metadata !4, i64 0, metadata !11, i64 8}
!28 = metadata !{metadata !7, metadata !3, i64 8}
!29 = metadata !{metadata !20, metadata !11, i64 28}
!30 = metadata !{metadata !13, metadata !3, i64 4}
!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 !28, metadata !11, i64 8}
!28 = metadata !{metadata !"TValue", metadata !4, i64 0, metadata !11, i64 8}
!29 = metadata !{metadata !7, metadata !3, i64 8}
!30 = metadata !{metadata !20, metadata !11, i64 28}
!31 = metadata !{metadata !13, metadata !3, i64 4}

@ -0,0 +1,298 @@
#ifndef HEADER
#define HEADER
struct GCObject {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
};
struct lua_State;
union Value {
struct GCObject *gc;
void *p;
int b;
int (*f)(struct lua_State *);
long long i;
double n;
};
struct TValue {
union Value value_;
int tt_;
};
struct TString {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char extra;
unsigned int hash;
unsigned long long len;
struct TString *hnext;
};
union MaxAlign {
double u;
void *s;
long long i;
long l;
};
union UTString {
union MaxAlign dummy;
struct TString tsv;
};
struct Udata {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char ttuv_; /* user value's tag */
struct Table *metatable;
unsigned long long len; /* number of bytes */
union Value user_; /* user value */
};
union UUdata {
union MaxAlign dummy; /* ensures maximum alignment for 'local' udata */
struct Udata uv;
};
enum ravitype_t {
RAVI_TANY, /* Lua dynamic type */
RAVI_TNUMINT, /* integer number */
RAVI_TNUMFLT, /* floating point number */
RAVI_TARRAYINT, /* array of ints */
RAVI_TARRAYFLT, /* array of doubles */
RAVI_TFUNCTION,
RAVI_TTABLE,
RAVI_TSTRING,
RAVI_TNIL,
RAVI_TBOOLEAN
};
struct Upvaldesc {
struct TString *name; /* upvalue name (for debug information) */
enum ravitype_t type; /* RAVI type of upvalue */
unsigned char instack; /* whether it is in stack */
unsigned char
idx; /* index of upvalue (in stack or in outer function's list) */
};
struct LocVar {
struct TString *varname;
int startpc; /* first point where variable is active */
int endpc; /* first point where variable is dead */
enum ravitype_t
ravi_type; /* RAVI type of the variable - RAVI_TANY if unknown */
};
struct RaviJITProto {
unsigned char jit_status; // 0=not compiled, 1=can't compile, 2=compiled, 3=freed
void *jit_data;
int (*jit_function) (struct lua_State *);
};
struct Proto {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char numparams; /* number of fixed parameters */
unsigned char is_vararg;
unsigned char maxstacksize; /* maximum stack used by this function */
int sizeupvalues; /* size of 'upvalues' */
int sizek; /* size of 'k' */
int sizecode;
int sizelineinfo;
int sizep; /* size of 'p' */
int sizelocvars;
int linedefined;
int lastlinedefined;
struct TValue *k; /* constants used by the function */
unsigned int *code;
struct Proto **p; /* functions defined inside the function */
int *lineinfo; /* map from opcodes to source lines (debug information) */
struct LocVar *
locvars; /* information about local variables (debug information) */
struct Upvaldesc *upvalues; /* upvalue information */
struct LClosure *cache; /* last created closure with this prototype */
struct TString *source; /* used for debug information */
struct GCObject *gclist;
struct RaviJITProto ravi_jit;
};
struct UpVal;
struct CClosure {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char nupvalues;
struct GCObject *gclist;
int (*f)(struct lua_State *);
struct TValue upvalue[1]; /* list of upvalues */
};
struct LClosure {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char nupvalues;
struct GCObject *gclist;
struct Proto *p;
struct UpVal *upvals[1]; /* list of upvalues */
};
union Closure {
struct CClosure c;
struct LClosure l;
};
union TKey {
struct {
union Value value_;
int tt_;
int next; /* for chaining (offset for next node) */
} nk;
struct TValue tvk;
};
struct Node {
struct TValue i_val;
union TKey i_key;
};
struct RaviArray {
char *data;
enum ravitype_t type; /* RAVI specialization */
unsigned int len; /* RAVI len specialization */
unsigned int size; /* amount of memory allocated */
};
struct Table {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char flags; /* 1<<p means tagmethod(p) is not present */
unsigned char lsizenode; /* log2 of size of 'node' array */
unsigned int sizearray; /* size of 'array' array */
struct TValue *array; /* array part */
struct Node *node;
struct Node *lastfree; /* any free position is before this position */
struct Table *metatable;
struct GCObject *gclist;
struct RaviArray ravi_array;
};
struct Mbuffer {
char *buffer;
unsigned long long n;
unsigned long long buffsize;
};
struct stringtable {
struct TString **hash;
int nuse; /* number of elements */
int size;
};
struct lua_Debug;
typedef long long ptrdiff_t;
typedef ptrdiff_t lua_KContext;
typedef int (*lua_KFunction)(struct lua_State *L, int status, lua_KContext ctx);
typedef void *(*lua_Alloc)(void *ud, void *ptr, unsigned long long osize,
unsigned long long nsize);
typedef void (*lua_Hook)(struct lua_State *L, struct lua_Debug *ar);
struct CallInfoL { /* only for Lua functions */
struct TValue *base; /* base for this function */
const unsigned int *savedpc;
ptrdiff_t dummy;
};
struct CallInfoC { /* only for C functions */
lua_KFunction k; /* continuation in case of yields */
ptrdiff_t old_errfunc;
lua_KContext ctx; /* context info. in case of yields */
};
struct CallInfo {
struct TValue *func; /* function index in the stack */
struct TValue *top; /* top for this function */
struct CallInfo *previous, *next; /* dynamic call link */
union {
struct CallInfoL l;
struct CallInfoC c;
} u;
ptrdiff_t extra;
short nresults; /* expected number of results from this function */
unsigned char callstatus;
unsigned char jitstatus;
};
struct CallInfoLua {
struct TValue *func; /* function index in the stack */
struct TValue *top; /* top for this function */
struct CallInfo *previous, *next; /* dynamic call link */
struct CallInfoL l;
ptrdiff_t extra;
short nresults; /* expected number of results from this function */
unsigned char callstatus;
unsigned char jitstatus;
};
struct global_State;
struct lua_longjmp;
/*
** 'per thread' state
*/
struct lua_State {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char status;
struct TValue *top; /* first free slot in the stack */
struct global_State *l_G;
struct CallInfoLua *ci; /* call info for current function */
const unsigned int *oldpc; /* last pc traced */
struct TValue *stack_last; /* last free slot in the stack */
struct TValue *stack; /* stack base */
struct UpVal *openupval; /* list of open upvalues in this stack */
struct GCObject *gclist;
struct lua_State *twups; /* list of threads with open upvalues */
struct lua_longjmp *errorJmp; /* current error recover point */
struct CallInfo base_ci; /* CallInfo for first level (C calling Lua) */
lua_Hook hook;
ptrdiff_t errfunc; /* current error handling function (stack index) */
int stacksize;
int basehookcount;
int hookcount;
unsigned short nny; /* number of non-yieldable calls in stack */
unsigned short nCcalls; /* number of nested C calls */
unsigned char hookmask;
unsigned char allowhook;
};
struct UpVal {
struct TValue *v; /* points to stack or to its own value */
unsigned long long refcount; /* reference counter */
union {
struct { /* (when open) */
struct UpVal *next; /* linked list */
int touched; /* mark to avoid cycles with dead threads */
} open;
struct TValue value; /* the value (when closed) */
} u;
};
#define rttype(o) ((o)->tt_)
#define BIT_ISCOLLECTABLE (1 << 6)
#define iscollectable(o) (rttype(o) & BIT_ISCOLLECTABLE)
#define upisopen(up) ((up)->v != &(up)->u.value)
#endif

@ -1,271 +1,4 @@
extern int printf(const char *, ...);
struct GCObject {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
};
struct lua_State;
union Value {
struct GCObject *gc;
void *p;
int b;
int (*f)(struct lua_State *);
long long i;
double n;
};
struct TValue {
union Value value_;
int tt_;
};
struct TString {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char extra;
unsigned int hash;
unsigned long long len;
struct TString *hnext;
};
union MaxAlign {
double u;
void *s;
long long i;
long l;
};
union UTString {
union MaxAlign dummy;
struct TString tsv;
};
struct Udata {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char ttuv_; /* user value's tag */
struct Table *metatable;
unsigned long long len; /* number of bytes */
union Value user_; /* user value */
};
union UUdata {
union MaxAlign dummy; /* ensures maximum alignment for 'local' udata */
struct Udata uv;
};
struct Upvaldesc {
struct TString *name; /* upvalue name (for debug information) */
unsigned char instack; /* whether it is in stack */
unsigned char
idx; /* index of upvalue (in stack or in outer function's list) */
};
enum ravitype_t {
RAVI_TANY, /* Lua dynamic type */
RAVI_TNUMINT, /* integer number */
RAVI_TNUMFLT, /* floating point number */
RAVI_TARRAYINT, /* array of ints */
RAVI_TARRAYFLT, /* array of doubles */
RAVI_TFUNCTION,
RAVI_TTABLE,
RAVI_TSTRING,
RAVI_TNIL,
RAVI_TBOOLEAN
};
struct LocVar {
struct TString *varname;
int startpc; /* first point where variable is active */
int endpc; /* first point where variable is dead */
enum ravitype_t
ravi_type; /* RAVI type of the variable - RAVI_TANY if unknown */
};
struct Proto {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char numparams; /* number of fixed parameters */
unsigned char is_vararg;
unsigned char maxstacksize; /* maximum stack used by this function */
int sizeupvalues; /* size of 'upvalues' */
int sizek; /* size of 'k' */
int sizecode;
int sizelineinfo;
int sizep; /* size of 'p' */
int sizelocvars;
int linedefined;
int lastlinedefined;
struct TValue *k; /* constants used by the function */
unsigned int *code;
struct Proto **p; /* functions defined inside the function */
int *lineinfo; /* map from opcodes to source lines (debug information) */
struct LocVar *
locvars; /* information about local variables (debug information) */
struct Upvaldesc *upvalues; /* upvalue information */
struct LClosure *cache; /* last created closure with this prototype */
struct TString *source; /* used for debug information */
struct GCObject *gclist;
} Proto;
struct UpVal;
struct CClosure {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char nupvalues;
struct GCObject *gclist;
int (*f)(struct lua_State *);
struct TValue upvalue[1]; /* list of upvalues */
};
struct LClosure {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char nupvalues;
struct GCObject *gclist;
struct Proto *p;
struct UpVal *upvals[1]; /* list of upvalues */
};
union Closure {
struct CClosure c;
struct LClosure l;
};
union TKey {
struct {
union Value value_;
int tt_;
int next; /* for chaining (offset for next node) */
} nk;
struct TValue tvk;
};
struct Node {
struct TValue i_val;
union TKey i_key;
};
struct Table {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char flags; /* 1<<p means tagmethod(p) is not present */
unsigned char lsizenode; /* log2 of size of 'node' array */
unsigned int sizearray; /* size of 'array' array */
struct TValue *array; /* array part */
struct Node *node;
struct Node *lastfree; /* any free position is before this position */
struct Table *metatable;
struct GCObject *gclist;
char *ravi_data;
enum ravitype_t ravi_array_type; /* RAVI specialization */
unsigned int ravi_array_len; /* RAVI len specialization */
unsigned int ravi_array_size; /* RAVI len specialization */
};
struct Mbuffer {
char *buffer;
unsigned long long n;
unsigned long long buffsize;
};
struct stringtable {
struct TString **hash;
int nuse; /* number of elements */
int size;
};
struct lua_Debug;
typedef long long ptrdiff_t;
typedef ptrdiff_t lua_KContext;
typedef int (*lua_KFunction)(struct lua_State *L, int status, lua_KContext ctx);
typedef void *(*lua_Alloc)(void *ud, void *ptr, unsigned long long osize,
unsigned long long nsize);
typedef void (*lua_Hook)(struct lua_State *L, struct lua_Debug *ar);
struct CallInfoL { /* only for Lua functions */
struct TValue *base; /* base for this function */
const unsigned int *savedpc;
ptrdiff_t dummy;
};
struct CallInfoC { /* only for C functions */
lua_KFunction k; /* continuation in case of yields */
ptrdiff_t old_errfunc;
lua_KContext ctx; /* context info. in case of yields */
};
struct CallInfo {
struct TValue *func; /* function index in the stack */
struct TValue *top; /* top for this function */
struct CallInfo *previous, *next; /* dynamic call link */
union {
struct CallInfoL l;
struct CallInfoC c;
} u;
ptrdiff_t extra;
short nresults; /* expected number of results from this function */
unsigned char callstatus;
unsigned char jitstatus;
};
struct CallInfoLua {
struct TValue *func; /* function index in the stack */
struct TValue *top; /* top for this function */
struct CallInfo *previous, *next; /* dynamic call link */
struct CallInfoL l;
ptrdiff_t extra;
short nresults; /* expected number of results from this function */
unsigned char callstatus;
unsigned char jitstatus;
};
struct global_State;
struct lua_longjmp;
/*
** 'per thread' state
*/
struct lua_State {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char status;
struct TValue *top; /* first free slot in the stack */
struct global_State *l_G;
struct CallInfoLua *ci; /* call info for current function */
const unsigned int *oldpc; /* last pc traced */
struct TValue *stack_last; /* last free slot in the stack */
struct TValue *stack; /* stack base */
struct UpVal *openupval; /* list of open upvalues in this stack */
struct GCObject *gclist;
struct lua_State *twups; /* list of threads with open upvalues */
struct lua_longjmp *errorJmp; /* current error recover point */
struct CallInfo base_ci; /* CallInfo for first level (C calling Lua) */
lua_Hook hook;
ptrdiff_t errfunc; /* current error handling function (stack index) */
int stacksize;
int basehookcount;
int hookcount;
unsigned short nny; /* number of non-yieldable calls in stack */
unsigned short nCcalls; /* number of nested C calls */
unsigned char hookmask;
unsigned char allowhook;
};
void testfunc(struct GCObject *obj) { printf("value = %d\n", obj->tt); }
extern int luaD_poscall(struct lua_State *L, struct TValue *ra);
#include "lua_hdr.h"
/*
The following represents a C version of the Lua function:
@ -307,6 +40,11 @@ extern int luaD_poscall(struct lua_State *L, struct TValue *ra);
0 y 1 14
upvalues (0) for 000000D6D5D26630:
*/
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);
void test1(struct lua_State *L) {
/* This is the function prologue */

@ -2,27 +2,28 @@
target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"
target triple = "i686-pc-windows-gnu"
%struct.Proto = type { %struct.GCObject*, i8, i8, i8, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, %struct.TValue*, i32*, %struct.Proto**, i32*, %struct.LocVar*, %struct.Upvaldesc*, %struct.LClosure*, %struct.TString*, %struct.GCObject* }
%struct.TValue = type { %union.Value, i32 }
%union.Value = type { i64 }
%struct.LocVar = type { %struct.TString*, i32, i32, i32 }
%struct.Upvaldesc = type { %struct.TString*, i8, i8 }
%struct.LClosure = type { %struct.GCObject*, i8, i8, i8, %struct.GCObject*, %struct.Proto*, [1 x %struct.UpVal*] }
%struct.UpVal = type opaque
%struct.TString = type { %struct.GCObject*, i8, i8, i8, i32, i64, %struct.TString* }
%struct.GCObject = type { %struct.GCObject*, i8, i8 }
%struct.lua_State = type { %struct.GCObject*, i8, i8, i8, %struct.TValue*, %struct.global_State*, %struct.CallInfoLua*, i32*, %struct.TValue*, %struct.TValue*, %struct.UpVal*, %struct.GCObject*, %struct.lua_State*, %struct.lua_longjmp*, %struct.CallInfo, void (%struct.lua_State*, %struct.lua_Debug*)*, i64, i32, i32, i32, i16, i16, i8, i8 }
%struct.global_State = type opaque
%struct.CallInfoLua = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %struct.CallInfoL, i64, i16, i8 }
%struct.CallInfoLua = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %struct.CallInfoL, i64, i16, i8, i8 }
%struct.CallInfoL = type { %struct.TValue*, i32*, i64 }
%struct.TValue = type { %union.Value, i32 }
%union.Value = type { i64 }
%struct.UpVal = type { %struct.TValue*, i64, %union.anon.0 }
%union.anon.0 = type { %struct.TValue }
%struct.lua_longjmp = type opaque
%struct.CallInfo = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %union.anon, i64, i16, i8 }
%struct.CallInfo = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %union.anon, i64, i16, i8, i8 }
%union.anon = type { %struct.CallInfoC }
%struct.CallInfoC = type { i32 (%struct.lua_State*, i32, i64)*, i64, i64 }
%struct.lua_Debug = type opaque
%struct.LClosure = type { %struct.GCObject*, i8, i8, i8, %struct.GCObject*, %struct.Proto*, [1 x %struct.UpVal*] }
%struct.Proto = type { %struct.GCObject*, i8, i8, i8, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, %struct.TValue*, i32*, %struct.Proto**, i32*, %struct.LocVar*, %struct.Upvaldesc*, %struct.LClosure*, %struct.TString*, %struct.GCObject*, %struct.RaviJITProto }
%struct.LocVar = type { %struct.TString*, i32, i32, i32 }
%struct.Upvaldesc = type { %struct.TString*, i32, i8, i8 }
%struct.TString = type { %struct.GCObject*, i8, i8, i8, i32, i64, %struct.TString* }
%struct.RaviJITProto = type { i8, i8*, i32 (%struct.lua_State*)* }
@.str = private unnamed_addr constant [12 x i8] c"value = %d\0A\00", align 1
@Proto = common global %struct.Proto zeroinitializer, align 4
; Function Attrs: nounwind
define void @testfunc(%struct.GCObject* nocapture readonly %obj) #0 {
@ -61,13 +62,13 @@ label3: ; preds = %entry
%add.ptr17 = getelementptr inbounds %struct.TValue* %6, i32 1
%8 = bitcast %struct.TValue* %add.ptr16 to i8*
%9 = bitcast %struct.TValue* %add.ptr17 to i8*
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %8, i8* %9, i32 16, i32 8, i1 false), !tbaa.struct !21
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %8, i8* %9, i32 16, i32 8, i1 false), !tbaa.struct !22
%add.ptr20 = getelementptr inbounds %struct.TValue* %7, i32 2
%top = getelementptr inbounds %struct.lua_State* %L, i32 0, i32 4
store %struct.TValue* %add.ptr20, %struct.TValue** %top, align 4, !tbaa !26
store %struct.TValue* %add.ptr20, %struct.TValue** %top, align 4, !tbaa !27
%10 = load %struct.Proto** %p, align 4, !tbaa !17
%sizep = getelementptr inbounds %struct.Proto* %10, i32 0, i32 10
%11 = load i32* %sizep, align 4, !tbaa !27
%11 = load i32* %sizep, align 4, !tbaa !28
%cmp22 = icmp sgt i32 %11, 0
br i1 %cmp22, label %if.then23, label %if.end25
@ -82,8 +83,8 @@ if.end25: ; preds = %if.then23, %label3
if.then27: ; preds = %if.end25
%top28 = getelementptr inbounds %struct.CallInfoLua* %0, i32 0, i32 1
%12 = load %struct.TValue** %top28, align 4, !tbaa !28
store %struct.TValue* %12, %struct.TValue** %top, align 4, !tbaa !26
%12 = load %struct.TValue** %top28, align 4, !tbaa !29
store %struct.TValue* %12, %struct.TValue** %top, align 4, !tbaa !27
br label %return
label6: ; preds = %entry
@ -98,13 +99,13 @@ label8: ; preds = %label6
%add.ptr50 = getelementptr inbounds %struct.TValue* %6, i32 3
%14 = bitcast %struct.TValue* %add.ptr67 to i8*
%15 = bitcast %struct.TValue* %add.ptr50 to i8*
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %14, i8* %15, i32 16, i32 8, i1 false), !tbaa.struct !21
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %14, i8* %15, i32 16, i32 8, i1 false), !tbaa.struct !22
%add.ptr53 = getelementptr inbounds %struct.TValue* %13, i32 2
%top54 = getelementptr inbounds %struct.lua_State* %L, i32 0, i32 4
store %struct.TValue* %add.ptr53, %struct.TValue** %top54, align 4, !tbaa !26
store %struct.TValue* %add.ptr53, %struct.TValue** %top54, align 4, !tbaa !27
%16 = load %struct.Proto** %p, align 4, !tbaa !17
%sizep56 = getelementptr inbounds %struct.Proto* %16, i32 0, i32 10
%17 = load i32* %sizep56, align 4, !tbaa !27
%17 = load i32* %sizep56, align 4, !tbaa !28
%cmp57 = icmp sgt i32 %17, 0
br i1 %cmp57, label %if.then58, label %if.end60
@ -119,21 +120,21 @@ if.end60: ; preds = %if.then58, %label8
if.then63: ; preds = %if.end60
%top64 = getelementptr inbounds %struct.CallInfoLua* %0, i32 0, i32 1
%18 = load %struct.TValue** %top64, align 4, !tbaa !28
store %struct.TValue* %18, %struct.TValue** %top54, align 4, !tbaa !26
%18 = load %struct.TValue** %top64, align 4, !tbaa !29
store %struct.TValue* %18, %struct.TValue** %top54, align 4, !tbaa !27
br label %return
label11: ; preds = %label6
%add.ptr68 = getelementptr inbounds %struct.TValue* %6, i32 4
%19 = bitcast %struct.TValue* %add.ptr67 to i8*
%20 = bitcast %struct.TValue* %add.ptr68 to i8*
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %19, i8* %20, i32 16, i32 8, i1 false), !tbaa.struct !21
tail call void @llvm.memcpy.p0i8.p0i8.i32(i8* %19, i8* %20, i32 16, i32 8, i1 false), !tbaa.struct !22
%add.ptr71 = getelementptr inbounds %struct.TValue* %13, i32 2
%top72 = getelementptr inbounds %struct.lua_State* %L, i32 0, i32 4
store %struct.TValue* %add.ptr71, %struct.TValue** %top72, align 4, !tbaa !26
store %struct.TValue* %add.ptr71, %struct.TValue** %top72, align 4, !tbaa !27
%21 = load %struct.Proto** %p, align 4, !tbaa !17
%sizep74 = getelementptr inbounds %struct.Proto* %21, i32 0, i32 10
%22 = load i32* %sizep74, align 4, !tbaa !27
%22 = load i32* %sizep74, align 4, !tbaa !28
%cmp75 = icmp sgt i32 %22, 0
br i1 %cmp75, label %if.then76, label %if.end78
@ -148,8 +149,8 @@ if.end78: ; preds = %if.then76, %label11
if.then81: ; preds = %if.end78
%top82 = getelementptr inbounds %struct.CallInfoLua* %0, i32 0, i32 1
%23 = load %struct.TValue** %top82, align 4, !tbaa !28
store %struct.TValue* %23, %struct.TValue** %top72, align 4, !tbaa !26
%23 = load %struct.TValue** %top82, align 4, !tbaa !29
store %struct.TValue* %23, %struct.TValue** %top72, align 4, !tbaa !27
br label %return
return: ; preds = %if.end78, %if.end60, %if.end25, %if.then81, %if.then63, %if.then27
@ -179,24 +180,25 @@ attributes #2 = { nounwind }
!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}
!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}
!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}
!21 = metadata !{i64 0, i64 4, metadata !16, i64 0, i64 4, metadata !16, i64 0, i64 4, metadata !22, i64 0, i64 4, metadata !16, i64 0, i64 8, metadata !23, i64 0, i64 8, metadata !24, i64 8, i64 4, metadata !22}
!22 = metadata !{metadata !11, metadata !11, i64 0}
!23 = metadata !{metadata !9, metadata !9, i64 0}
!24 = metadata !{metadata !25, metadata !25, i64 0}
!25 = metadata !{metadata !"double", metadata !4, i64 0}
!26 = metadata !{metadata !7, metadata !3, i64 8}
!27 = metadata !{metadata !20, metadata !11, i64 28}
!28 = metadata !{metadata !13, metadata !3, i64 4}
!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}

@ -1,269 +1,6 @@
extern int printf(const char *, ...);
struct GCObject {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
};
struct lua_State;
union Value {
struct GCObject *gc;
void *p;
int b;
int (*f)(struct lua_State *);
long long i;
double n;
};
struct TValue {
union Value value_;
int tt_;
};
struct TString {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char extra;
unsigned int hash;
unsigned long long len;
struct TString *hnext;
};
union MaxAlign {
double u;
void *s;
long long i;
long l;
};
union UTString {
union MaxAlign dummy;
struct TString tsv;
};
struct Udata {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char ttuv_; /* user value's tag */
struct Table *metatable;
unsigned long long len; /* number of bytes */
union Value user_; /* user value */
};
union UUdata {
union MaxAlign dummy; /* ensures maximum alignment for 'local' udata */
struct Udata uv;
};
struct Upvaldesc {
struct TString *name; /* upvalue name (for debug information) */
unsigned char instack; /* whether it is in stack */
unsigned char
idx; /* index of upvalue (in stack or in outer function's list) */
};
enum ravitype_t {
RAVI_TANY, /* Lua dynamic type */
RAVI_TNUMINT, /* integer number */
RAVI_TNUMFLT, /* floating point number */
RAVI_TARRAYINT, /* array of ints */
RAVI_TARRAYFLT, /* array of doubles */
RAVI_TFUNCTION,
RAVI_TTABLE,
RAVI_TSTRING,
RAVI_TNIL,
RAVI_TBOOLEAN
};
struct LocVar {
struct TString *varname;
int startpc; /* first point where variable is active */
int endpc; /* first point where variable is dead */
enum ravitype_t
ravi_type; /* RAVI type of the variable - RAVI_TANY if unknown */
};
struct Proto {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char numparams; /* number of fixed parameters */
unsigned char is_vararg;
unsigned char maxstacksize; /* maximum stack used by this function */
int sizeupvalues; /* size of 'upvalues' */
int sizek; /* size of 'k' */
int sizecode;
int sizelineinfo;
int sizep; /* size of 'p' */
int sizelocvars;
int linedefined;
int lastlinedefined;
struct TValue *k; /* constants used by the function */
unsigned int *code;
struct Proto **p; /* functions defined inside the function */
int *lineinfo; /* map from opcodes to source lines (debug information) */
struct LocVar *
locvars; /* information about local variables (debug information) */
struct Upvaldesc *upvalues; /* upvalue information */
struct LClosure *cache; /* last created closure with this prototype */
struct TString *source; /* used for debug information */
struct GCObject *gclist;
} Proto;
struct UpVal;
struct CClosure {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char nupvalues;
struct GCObject *gclist;
int (*f)(struct lua_State *);
struct TValue upvalue[1]; /* list of upvalues */
};
struct LClosure {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char nupvalues;
struct GCObject *gclist;
struct Proto *p;
struct UpVal *upvals[1]; /* list of upvalues */
};
union Closure {
struct CClosure c;
struct LClosure l;
};
union TKey {
struct {
union Value value_;
int tt_;
int next; /* for chaining (offset for next node) */
} nk;
struct TValue tvk;
};
struct Node {
struct TValue i_val;
union TKey i_key;
};
struct Table {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char flags; /* 1<<p means tagmethod(p) is not present */
unsigned char lsizenode; /* log2 of size of 'node' array */
unsigned int sizearray; /* size of 'array' array */
struct TValue *array; /* array part */
struct Node *node;
struct Node *lastfree; /* any free position is before this position */
struct Table *metatable;
struct GCObject *gclist;
char *ravi_data;
enum ravitype_t ravi_array_type; /* RAVI specialization */
unsigned int ravi_array_len; /* RAVI len specialization */
unsigned int ravi_array_size; /* RAVI len specialization */
};
struct Mbuffer {
char *buffer;
unsigned long long n;
unsigned long long buffsize;
};
struct stringtable {
struct TString **hash;
int nuse; /* number of elements */
int size;
};
struct lua_Debug;
typedef long long ptrdiff_t;
typedef ptrdiff_t lua_KContext;
typedef int (*lua_KFunction)(struct lua_State *L, int status, lua_KContext ctx);
typedef void *(*lua_Alloc)(void *ud, void *ptr, unsigned long long osize,
unsigned long long nsize);
typedef void (*lua_Hook)(struct lua_State *L, struct lua_Debug *ar);
struct CallInfoL { /* only for Lua functions */
struct TValue *base; /* base for this function */
const unsigned int *savedpc;
ptrdiff_t dummy;
};
struct CallInfoC { /* only for C functions */
lua_KFunction k; /* continuation in case of yields */
ptrdiff_t old_errfunc;
lua_KContext ctx; /* context info. in case of yields */
};
struct CallInfo {
struct TValue *func; /* function index in the stack */
struct TValue *top; /* top for this function */
struct CallInfo *previous, *next; /* dynamic call link */
union {
struct CallInfoL l;
struct CallInfoC c;
} u;
ptrdiff_t extra;
short nresults; /* expected number of results from this function */
unsigned char callstatus;
unsigned char jitstatus;
};
struct CallInfoLua {
struct TValue *func; /* function index in the stack */
struct TValue *top; /* top for this function */
struct CallInfo *previous, *next; /* dynamic call link */
struct CallInfoL l;
ptrdiff_t extra;
short nresults; /* expected number of results from this function */
unsigned char callstatus;
unsigned char jitstatus;
};
struct global_State;
struct lua_longjmp;
/*
** 'per thread' state
*/
struct lua_State {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char status;
struct TValue *top; /* first free slot in the stack */
struct global_State *l_G;
struct CallInfoLua *ci; /* call info for current function */
const unsigned int *oldpc; /* last pc traced */
struct TValue *stack_last; /* last free slot in the stack */
struct TValue *stack; /* stack base */
struct UpVal *openupval; /* list of open upvalues in this stack */
struct GCObject *gclist;
struct lua_State *twups; /* list of threads with open upvalues */
struct lua_longjmp *errorJmp; /* current error recover point */
struct CallInfo base_ci; /* CallInfo for first level (C calling Lua) */
lua_Hook hook;
ptrdiff_t errfunc; /* current error handling function (stack index) */
int stacksize;
int basehookcount;
int hookcount;
unsigned short nny; /* number of non-yieldable calls in stack */
unsigned short nCcalls; /* number of nested C calls */
unsigned char hookmask;
unsigned char allowhook;
};
#include "lua_hdr.h"
extern int printf(const char *, ...);
extern int luaD_precall (struct lua_State *L, struct TValue *func, int nresults, int compile);
extern void luaV_execute(struct lua_State *L);

@ -2,27 +2,21 @@
target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"
target triple = "i686-pc-windows-gnu"
%struct.Proto = type { %struct.GCObject*, i8, i8, i8, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, %struct.TValue*, i32*, %struct.Proto**, i32*, %struct.LocVar*, %struct.Upvaldesc*, %struct.LClosure*, %struct.TString*, %struct.GCObject* }
%struct.TValue = type { %union.Value, i32 }
%union.Value = type { i64 }
%struct.LocVar = type { %struct.TString*, i32, i32, i32 }
%struct.Upvaldesc = type { %struct.TString*, i8, i8 }
%struct.LClosure = type { %struct.GCObject*, i8, i8, i8, %struct.GCObject*, %struct.Proto*, [1 x %struct.UpVal*] }
%struct.UpVal = type opaque
%struct.TString = type { %struct.GCObject*, i8, i8, i8, i32, i64, %struct.TString* }
%struct.GCObject = type { %struct.GCObject*, i8, i8 }
%struct.lua_State = type { %struct.GCObject*, i8, i8, i8, %struct.TValue*, %struct.global_State*, %struct.CallInfoLua*, i32*, %struct.TValue*, %struct.TValue*, %struct.UpVal*, %struct.GCObject*, %struct.lua_State*, %struct.lua_longjmp*, %struct.CallInfo, void (%struct.lua_State*, %struct.lua_Debug*)*, i64, i32, i32, i32, i16, i16, i8, i8 }
%struct.global_State = type opaque
%struct.CallInfoLua = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %struct.CallInfoL, i64, i16, i8 }
%struct.CallInfoLua = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %struct.CallInfoL, i64, i16, i8, i8 }
%struct.CallInfoL = type { %struct.TValue*, i32*, i64 }
%struct.UpVal = type { %struct.TValue*, i64, %union.anon.0 }
%union.anon.0 = type { %struct.TValue }
%struct.TValue = type { %union.Value, i32 }
%union.Value = type { i64 }
%struct.GCObject = type { %struct.GCObject*, i8, i8 }
%struct.lua_longjmp = type opaque
%struct.CallInfo = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %union.anon, i64, i16, i8 }
%struct.CallInfo = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %union.anon, i64, i16, i8, i8 }
%union.anon = type { %struct.CallInfoC }
%struct.CallInfoC = type { i32 (%struct.lua_State*, i32, i64)*, i64, i64 }
%struct.lua_Debug = type opaque
@Proto = common global %struct.Proto zeroinitializer, align 4
; Function Attrs: nounwind
define void @luaV_op_call(%struct.lua_State* %L, %struct.CallInfo* nocapture readonly %ci, %struct.TValue* %ra, i32 %b, i32 %c) #0 {
entry:
@ -42,21 +36,23 @@ if.end: ; preds = %entry, %if.then
br i1 %tobool, label %if.else, label %if.then1
if.then1: ; preds = %if.end
%cmp2 = icmp sgt i32 %c, 0
br i1 %cmp2, label %if.then3, label %if.end7
%cmp2 = icmp eq i32 %call, 1
%cmp3 = icmp sgt i32 %c, 0
%or.cond = and i1 %cmp3, %cmp2
br i1 %or.cond, label %if.then4, label %if.end8
if.then3: ; preds = %if.then1
%top4 = getelementptr inbounds %struct.CallInfo* %ci, i32 0, i32 1
%0 = load %struct.TValue** %top4, align 4, !tbaa !10
%top5 = getelementptr inbounds %struct.lua_State* %L, i32 0, i32 4
store %struct.TValue* %0, %struct.TValue** %top5, align 4, !tbaa !1
br label %if.end7
if.then4: ; preds = %if.then1
%top5 = getelementptr inbounds %struct.CallInfo* %ci, i32 0, i32 1
%0 = load %struct.TValue** %top5, align 4, !tbaa !10
%top6 = getelementptr inbounds %struct.lua_State* %L, i32 0, i32 4
store %struct.TValue* %0, %struct.TValue** %top6, align 4, !tbaa !1
br label %if.end8
if.else: ; preds = %if.end
tail call void @luaV_execute(%struct.lua_State* %L) #2
br label %if.end7
br label %if.end8
if.end7: ; preds = %if.then1, %if.then3, %if.else
if.end8: ; preds = %if.then1, %if.then4, %if.else
ret void
}
@ -76,7 +72,7 @@ attributes #2 = { nounwind }
!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 !"CallInfo", metadata !3, i64 0, metadata !3, i64 4, metadata !3, i64 8, metadata !3, i64 12, metadata !4, i64 16, metadata !7, i64 40, metadata !8, i64 48, metadata !4, i64 50}
!6 = metadata !{metadata !"CallInfo", metadata !3, i64 0, metadata !3, i64 4, metadata !3, i64 8, metadata !3, i64 12, metadata !4, i64 16, metadata !7, i64 40, metadata !8, i64 48, metadata !4, i64 50, metadata !4, i64 51}
!7 = metadata !{metadata !"long long", metadata !4, i64 0}
!8 = metadata !{metadata !"short", metadata !4, i64 0}
!9 = metadata !{metadata !"int", metadata !4, i64 0}

@ -1,271 +1,4 @@
extern int printf(const char *, ...);
struct GCObject {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
};
struct lua_State;
union Value {
struct GCObject *gc;
void *p;
int b;
int (*f)(struct lua_State *);
long long i;
double n;
};
struct TValue {
union Value value_;
int tt_;
};
struct TString {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char extra;
unsigned int hash;
unsigned long long len;
struct TString *hnext;
};
union MaxAlign {
double u;
void *s;
long long i;
long l;
};
union UTString {
union MaxAlign dummy;
struct TString tsv;
};
struct Udata {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char ttuv_; /* user value's tag */
struct Table *metatable;
unsigned long long len; /* number of bytes */
union Value user_; /* user value */
};
union UUdata {
union MaxAlign dummy; /* ensures maximum alignment for 'local' udata */
struct Udata uv;
};
struct Upvaldesc {
struct TString *name; /* upvalue name (for debug information) */
unsigned char instack; /* whether it is in stack */
unsigned char
idx; /* index of upvalue (in stack or in outer function's list) */
};
enum ravitype_t {
RAVI_TANY, /* Lua dynamic type */
RAVI_TNUMINT, /* integer number */
RAVI_TNUMFLT, /* floating point number */
RAVI_TARRAYINT, /* array of ints */
RAVI_TARRAYFLT, /* array of doubles */
RAVI_TFUNCTION,
RAVI_TTABLE,
RAVI_TSTRING,
RAVI_TNIL,
RAVI_TBOOLEAN
};
struct LocVar {
struct TString *varname;
int startpc; /* first point where variable is active */
int endpc; /* first point where variable is dead */
enum ravitype_t
ravi_type; /* RAVI type of the variable - RAVI_TANY if unknown */
};
struct Proto {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char numparams; /* number of fixed parameters */
unsigned char is_vararg;
unsigned char maxstacksize; /* maximum stack used by this function */
int sizeupvalues; /* size of 'upvalues' */
int sizek; /* size of 'k' */
int sizecode;
int sizelineinfo;
int sizep; /* size of 'p' */
int sizelocvars;
int linedefined;
int lastlinedefined;
struct TValue *k; /* constants used by the function */
unsigned int *code;
struct Proto **p; /* functions defined inside the function */
int *lineinfo; /* map from opcodes to source lines (debug information) */
struct LocVar *
locvars; /* information about local variables (debug information) */
struct Upvaldesc *upvalues; /* upvalue information */
struct LClosure *cache; /* last created closure with this prototype */
struct TString *source; /* used for debug information */
struct GCObject *gclist;
} Proto;
struct UpVal;
struct CClosure {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char nupvalues;
struct GCObject *gclist;
int (*f)(struct lua_State *);
struct TValue upvalue[1]; /* list of upvalues */
};
struct LClosure {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char nupvalues;
struct GCObject *gclist;
struct Proto *p;
struct UpVal *upvals[1]; /* list of upvalues */
};
union Closure {
struct CClosure c;
struct LClosure l;
};
union TKey {
struct {
union Value value_;
int tt_;
int next; /* for chaining (offset for next node) */
} nk;
struct TValue tvk;
};
struct Node {
struct TValue i_val;
union TKey i_key;
};
struct Table {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char flags; /* 1<<p means tagmethod(p) is not present */
unsigned char lsizenode; /* log2 of size of 'node' array */
unsigned int sizearray; /* size of 'array' array */
struct TValue *array; /* array part */
struct Node *node;
struct Node *lastfree; /* any free position is before this position */
struct Table *metatable;
struct GCObject *gclist;
char *ravi_data;
enum ravitype_t ravi_array_type; /* RAVI specialization */
unsigned int ravi_array_len; /* RAVI len specialization */
unsigned int ravi_array_size; /* RAVI len specialization */
};
struct Mbuffer {
char *buffer;
unsigned long long n;
unsigned long long buffsize;
};
struct stringtable {
struct TString **hash;
int nuse; /* number of elements */
int size;
};
struct lua_Debug;
typedef long long ptrdiff_t;
typedef ptrdiff_t lua_KContext;
typedef int (*lua_KFunction)(struct lua_State *L, int status, lua_KContext ctx);
typedef void *(*lua_Alloc)(void *ud, void *ptr, unsigned long long osize,
unsigned long long nsize);
typedef void (*lua_Hook)(struct lua_State *L, struct lua_Debug *ar);
struct CallInfoL { /* only for Lua functions */
struct TValue *base; /* base for this function */
const unsigned int *savedpc;
ptrdiff_t dummy;
};
struct CallInfoC { /* only for C functions */
lua_KFunction k; /* continuation in case of yields */
ptrdiff_t old_errfunc;
lua_KContext ctx; /* context info. in case of yields */
};
struct CallInfo {
struct TValue *func; /* function index in the stack */
struct TValue *top; /* top for this function */
struct CallInfo *previous, *next; /* dynamic call link */
union {
struct CallInfoL l;
struct CallInfoC c;
} u;
ptrdiff_t extra;
short nresults; /* expected number of results from this function */
unsigned char callstatus;
unsigned char jitstatus;
};
struct CallInfoLua {
struct TValue *func; /* function index in the stack */
struct TValue *top; /* top for this function */
struct CallInfo *previous, *next; /* dynamic call link */
struct CallInfoL l;
ptrdiff_t extra;
short nresults; /* expected number of results from this function */
unsigned char callstatus;
unsigned char jitstatus;
};
struct global_State;
struct lua_longjmp;
/*
** 'per thread' state
*/
struct lua_State {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char status;
struct TValue *top; /* first free slot in the stack */
struct global_State *l_G;
struct CallInfoLua *ci; /* call info for current function */
const unsigned int *oldpc; /* last pc traced */
struct TValue *stack_last; /* last free slot in the stack */
struct TValue *stack; /* stack base */
struct UpVal *openupval; /* list of open upvalues in this stack */
struct GCObject *gclist;
struct lua_State *twups; /* list of threads with open upvalues */
struct lua_longjmp *errorJmp; /* current error recover point */
struct CallInfo base_ci; /* CallInfo for first level (C calling Lua) */
lua_Hook hook;
ptrdiff_t errfunc; /* current error handling function (stack index) */
int stacksize;
int basehookcount;
int hookcount;
unsigned short nny; /* number of non-yieldable calls in stack */
unsigned short nCcalls; /* number of nested C calls */
unsigned char hookmask;
unsigned char allowhook;
};
void testfunc(struct GCObject *obj) { printf("value = %d\n", obj->tt); }
extern int luaD_poscall(struct lua_State *L, struct TValue *ra);
#include "lua_hdr.h"
/*
The following represents a C version of the Lua function:
@ -304,6 +37,9 @@ extern int luaD_poscall(struct lua_State *L, struct TValue *ra);
upvalues (0) for 00000014E5C8E380:
*/
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 forlimit(const struct TValue *obj, long long int *p, long long int step,
int *stopnow);
extern int luaV_tonumber_(const struct TValue *obj, double *n);

@ -2,28 +2,23 @@
target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"
target triple = "i686-pc-windows-gnu"
%struct.Proto = type { %struct.GCObject*, i8, i8, i8, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, %struct.TValue*, i32*, %struct.Proto**, i32*, %struct.LocVar*, %struct.Upvaldesc*, %struct.LClosure*, %struct.TString*, %struct.GCObject* }
%struct.TValue = type { %union.Value, i32 }
%union.Value = type { i64 }
%struct.LocVar = type { %struct.TString*, i32, i32, i32 }
%struct.Upvaldesc = type { %struct.TString*, i8, i8 }
%struct.LClosure = type { %struct.GCObject*, i8, i8, i8, %struct.GCObject*, %struct.Proto*, [1 x %struct.UpVal*] }
%struct.UpVal = type opaque
%struct.TString = type { %struct.GCObject*, i8, i8, i8, i32, i64, %struct.TString* }
%struct.GCObject = type { %struct.GCObject*, i8, i8 }
%struct.lua_State = type { %struct.GCObject*, i8, i8, i8, %struct.TValue*, %struct.global_State*, %struct.CallInfoLua*, i32*, %struct.TValue*, %struct.TValue*, %struct.UpVal*, %struct.GCObject*, %struct.lua_State*, %struct.lua_longjmp*, %struct.CallInfo, void (%struct.lua_State*, %struct.lua_Debug*)*, i64, i32, i32, i32, i16, i16, i8, i8 }
%struct.global_State = type opaque
%struct.CallInfoLua = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %struct.CallInfoL, i64, i16, i8 }
%struct.CallInfoLua = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %struct.CallInfoL, i64, i16, i8, i8 }
%struct.CallInfoL = type { %struct.TValue*, i32*, i64 }
%struct.TValue = type { %union.Value, i32 }
%union.Value = type { i64 }
%struct.UpVal = type { %struct.TValue*, i64, %union.anon.0 }
%union.anon.0 = type { %struct.TValue }
%struct.lua_longjmp = type opaque
%struct.CallInfo = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %union.anon, i64, i16, i8 }
%struct.CallInfo = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %union.anon, i64, i16, i8, i8 }
%union.anon = type { %struct.CallInfoC }
%struct.CallInfoC = type { i32 (%struct.lua_State*, i32, i64)*, i64, i64 }
%struct.lua_Debug = type opaque
@.str = private unnamed_addr constant [12 x i8] c"value = %d\0A\00", align 1
@.str1 = private unnamed_addr constant [6 x i8] c"dummy\00", align 1
@Proto = common global %struct.Proto zeroinitializer, align 4
; Function Attrs: nounwind
define void @testfunc(%struct.GCObject* nocapture readonly %obj) #0 {
@ -133,12 +128,12 @@ attributes #1 = { nounwind }
!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}
!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}
!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 !16, metadata !11, i64 8}
!16 = metadata !{metadata !"TValue", metadata !4, i64 0, metadata !11, i64 8}

@ -1,271 +1,4 @@
extern int printf(const char *, ...);
struct GCObject {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
};
struct lua_State;
union Value {
struct GCObject *gc;
void *p;
int b;
int (*f)(struct lua_State *);
long long i;
double n;
};
struct TValue {
union Value value_;
int tt_;
};
struct TString {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char extra;
unsigned int hash;
unsigned long long len;
struct TString *hnext;
};
union MaxAlign {
double u;
void *s;
long long i;
long l;
};
union UTString {
union MaxAlign dummy;
struct TString tsv;
};
struct Udata {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char ttuv_; /* user value's tag */
struct Table *metatable;
unsigned long long len; /* number of bytes */
union Value user_; /* user value */
};
union UUdata {
union MaxAlign dummy; /* ensures maximum alignment for 'local' udata */
struct Udata uv;
};
struct Upvaldesc {
struct TString *name; /* upvalue name (for debug information) */
unsigned char instack; /* whether it is in stack */
unsigned char
idx; /* index of upvalue (in stack or in outer function's list) */
};
enum ravitype_t {
RAVI_TANY, /* Lua dynamic type */
RAVI_TNUMINT, /* integer number */
RAVI_TNUMFLT, /* floating point number */
RAVI_TARRAYINT, /* array of ints */
RAVI_TARRAYFLT, /* array of doubles */
RAVI_TFUNCTION,
RAVI_TTABLE,
RAVI_TSTRING,
RAVI_TNIL,
RAVI_TBOOLEAN
};
struct LocVar {
struct TString *varname;
int startpc; /* first point where variable is active */
int endpc; /* first point where variable is dead */
enum ravitype_t
ravi_type; /* RAVI type of the variable - RAVI_TANY if unknown */
};
struct Proto {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char numparams; /* number of fixed parameters */
unsigned char is_vararg;
unsigned char maxstacksize; /* maximum stack used by this function */
int sizeupvalues; /* size of 'upvalues' */
int sizek; /* size of 'k' */
int sizecode;
int sizelineinfo;
int sizep; /* size of 'p' */
int sizelocvars;
int linedefined;
int lastlinedefined;
struct TValue *k; /* constants used by the function */
unsigned int *code;
struct Proto **p; /* functions defined inside the function */
int *lineinfo; /* map from opcodes to source lines (debug information) */
struct LocVar *
locvars; /* information about local variables (debug information) */
struct Upvaldesc *upvalues; /* upvalue information */
struct LClosure *cache; /* last created closure with this prototype */
struct TString *source; /* used for debug information */
struct GCObject *gclist;
} Proto;
struct UpVal;
struct CClosure {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char nupvalues;
struct GCObject *gclist;
int (*f)(struct lua_State *);
struct TValue upvalue[1]; /* list of upvalues */
};
struct LClosure {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char nupvalues;
struct GCObject *gclist;
struct Proto *p;
struct UpVal *upvals[1]; /* list of upvalues */
};
union Closure {
struct CClosure c;
struct LClosure l;
};
union TKey {
struct {
union Value value_;
int tt_;
int next; /* for chaining (offset for next node) */
} nk;
struct TValue tvk;
};
struct Node {
struct TValue i_val;
union TKey i_key;
};
struct Table {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char flags; /* 1<<p means tagmethod(p) is not present */
unsigned char lsizenode; /* log2 of size of 'node' array */
unsigned int sizearray; /* size of 'array' array */
struct TValue *array; /* array part */
struct Node *node;
struct Node *lastfree; /* any free position is before this position */
struct Table *metatable;
struct GCObject *gclist;
char *ravi_data;
enum ravitype_t ravi_array_type; /* RAVI specialization */
unsigned int ravi_array_len; /* RAVI len specialization */
unsigned int ravi_array_size; /* RAVI len specialization */
};
struct Mbuffer {
char *buffer;
unsigned long long n;
unsigned long long buffsize;
};
struct stringtable {
struct TString **hash;
int nuse; /* number of elements */
int size;
};
struct lua_Debug;
typedef long long ptrdiff_t;
typedef ptrdiff_t lua_KContext;
typedef int (*lua_KFunction)(struct lua_State *L, int status, lua_KContext ctx);
typedef void *(*lua_Alloc)(void *ud, void *ptr, unsigned long long osize,
unsigned long long nsize);
typedef void (*lua_Hook)(struct lua_State *L, struct lua_Debug *ar);
struct CallInfoL { /* only for Lua functions */
struct TValue *base; /* base for this function */
const unsigned int *savedpc;
ptrdiff_t dummy;
};
struct CallInfoC { /* only for C functions */
lua_KFunction k; /* continuation in case of yields */
ptrdiff_t old_errfunc;
lua_KContext ctx; /* context info. in case of yields */
};
struct CallInfo {
struct TValue *func; /* function index in the stack */
struct TValue *top; /* top for this function */
struct CallInfo *previous, *next; /* dynamic call link */
union {
struct CallInfoL l;
struct CallInfoC c;
} u;
ptrdiff_t extra;
short nresults; /* expected number of results from this function */
unsigned char callstatus;
unsigned char jitstatus;
};
struct CallInfoLua {
struct TValue *func; /* function index in the stack */
struct TValue *top; /* top for this function */
struct CallInfo *previous, *next; /* dynamic call link */
struct CallInfoL l;
ptrdiff_t extra;
short nresults; /* expected number of results from this function */
unsigned char callstatus;
unsigned char jitstatus;
};
struct global_State;
struct lua_longjmp;
/*
** 'per thread' state
*/
struct lua_State {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char status;
struct TValue *top; /* first free slot in the stack */
struct global_State *l_G;
struct CallInfoLua *ci; /* call info for current function */
const unsigned int *oldpc; /* last pc traced */
struct TValue *stack_last; /* last free slot in the stack */
struct TValue *stack; /* stack base */
struct UpVal *openupval; /* list of open upvalues in this stack */
struct GCObject *gclist;
struct lua_State *twups; /* list of threads with open upvalues */
struct lua_longjmp *errorJmp; /* current error recover point */
struct CallInfo base_ci; /* CallInfo for first level (C calling Lua) */
lua_Hook hook;
ptrdiff_t errfunc; /* current error handling function (stack index) */
int stacksize;
int basehookcount;
int hookcount;
unsigned short nny; /* number of non-yieldable calls in stack */
unsigned short nCcalls; /* number of nested C calls */
unsigned char hookmask;
unsigned char allowhook;
};
void testfunc(struct GCObject *obj) { printf("value = %d\n", obj->tt); }
extern int luaD_poscall(struct lua_State *L, struct TValue *ra);
#include "lua_hdr.h"
/*
The following represents a C version of the Lua function:
@ -304,6 +37,9 @@ extern int luaD_poscall(struct lua_State *L, struct TValue *ra);
upvalues (0) for 00000014E5C8E380:
*/
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 forlimit(const struct TValue *obj, long long int *p, long long int step,
int *stopnow);
extern int luaV_tonumber_(const struct TValue *obj, double *n);

@ -2,21 +2,17 @@
target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"
target triple = "i686-pc-windows-gnu"
%struct.Proto = type { %struct.GCObject*, i8, i8, i8, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, %struct.TValue*, i32*, %struct.Proto**, i32*, %struct.LocVar*, %struct.Upvaldesc*, %struct.LClosure*, %struct.TString*, %struct.GCObject* }
%struct.TValue = type { %union.Value, i32 }
%union.Value = type { i64 }
%struct.LocVar = type { %struct.TString*, i32, i32, i32 }
%struct.Upvaldesc = type { %struct.TString*, i8, i8 }
%struct.LClosure = type { %struct.GCObject*, i8, i8, i8, %struct.GCObject*, %struct.Proto*, [1 x %struct.UpVal*] }
%struct.UpVal = type opaque
%struct.TString = type { %struct.GCObject*, i8, i8, i8, i32, i64, %struct.TString* }
%struct.GCObject = type { %struct.GCObject*, i8, i8 }
%struct.lua_State = type { %struct.GCObject*, i8, i8, i8, %struct.TValue*, %struct.global_State*, %struct.CallInfoLua*, i32*, %struct.TValue*, %struct.TValue*, %struct.UpVal*, %struct.GCObject*, %struct.lua_State*, %struct.lua_longjmp*, %struct.CallInfo, void (%struct.lua_State*, %struct.lua_Debug*)*, i64, i32, i32, i32, i16, i16, i8, i8 }
%struct.global_State = type opaque
%struct.CallInfoLua = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %struct.CallInfoL, i64, i16, i8 }
%struct.CallInfoLua = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %struct.CallInfoL, i64, i16, i8, i8 }
%struct.CallInfoL = type { %struct.TValue*, i32*, i64 }
%struct.TValue = type { %union.Value, i32 }
%union.Value = type { i64 }
%struct.UpVal = type { %struct.TValue*, i64, %union.anon.0 }
%union.anon.0 = type { %struct.TValue }
%struct.lua_longjmp = type opaque
%struct.CallInfo = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %union.anon, i64, i16, i8 }
%struct.CallInfo = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %union.anon, i64, i16, i8, i8 }
%union.anon = type { %struct.CallInfoC }
%struct.CallInfoC = type { i32 (%struct.lua_State*, i32, i64)*, i64, i64 }
%struct.lua_Debug = type opaque
@ -25,7 +21,6 @@ target triple = "i686-pc-windows-gnu"
@.str1 = private unnamed_addr constant [29 x i8] c"'for' limit must be a number\00", align 1
@.str2 = private unnamed_addr constant [28 x i8] c"'for' step must be a number\00", align 1
@.str3 = private unnamed_addr constant [37 x i8] c"'for' initial value must be a number\00", align 1
@Proto = common global %struct.Proto zeroinitializer, align 4
; Function Attrs: nounwind
define void @testfunc(%struct.GCObject* nocapture readonly %obj) #0 {
@ -194,12 +189,12 @@ attributes #2 = { nounwind }
!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}
!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}
!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 !16, metadata !11, i64 8}
!16 = metadata !{metadata !"TValue", metadata !4, i64 0, metadata !11, i64 8}

@ -1,270 +1,7 @@
extern int printf(const char *, ...);
struct GCObject {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
};
struct lua_State;
union Value {
struct GCObject *gc;
void *p;
int b;
int (*f)(struct lua_State *);
long long i;
double n;
};
struct TValue {
union Value value_;
int tt_;
};
struct TString {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char extra;
unsigned int hash;
unsigned long long len;
struct TString *hnext;
};
union MaxAlign {
double u;
void *s;
long long i;
long l;
};
union UTString {
union MaxAlign dummy;
struct TString tsv;
};
struct Udata {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char ttuv_; /* user value's tag */
struct Table *metatable;
unsigned long long len; /* number of bytes */
union Value user_; /* user value */
};
union UUdata {
union MaxAlign dummy; /* ensures maximum alignment for 'local' udata */
struct Udata uv;
};
struct Upvaldesc {
struct TString *name; /* upvalue name (for debug information) */
unsigned char instack; /* whether it is in stack */
unsigned char
idx; /* index of upvalue (in stack or in outer function's list) */
};
enum ravitype_t {
RAVI_TANY, /* Lua dynamic type */
RAVI_TNUMINT, /* integer number */
RAVI_TNUMFLT, /* floating point number */
RAVI_TARRAYINT, /* array of ints */
RAVI_TARRAYFLT, /* array of doubles */
RAVI_TFUNCTION,
RAVI_TTABLE,
RAVI_TSTRING,
RAVI_TNIL,
RAVI_TBOOLEAN
};
struct LocVar {
struct TString *varname;
int startpc; /* first point where variable is active */
int endpc; /* first point where variable is dead */
enum ravitype_t
ravi_type; /* RAVI type of the variable - RAVI_TANY if unknown */
};
struct Proto {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char numparams; /* number of fixed parameters */
unsigned char is_vararg;
unsigned char maxstacksize; /* maximum stack used by this function */
int sizeupvalues; /* size of 'upvalues' */
int sizek; /* size of 'k' */
int sizecode;
int sizelineinfo;
int sizep; /* size of 'p' */
int sizelocvars;
int linedefined;
int lastlinedefined;
struct TValue *k; /* constants used by the function */
unsigned int *code;
struct Proto **p; /* functions defined inside the function */
int *lineinfo; /* map from opcodes to source lines (debug information) */
struct LocVar *
locvars; /* information about local variables (debug information) */
struct Upvaldesc *upvalues; /* upvalue information */
struct LClosure *cache; /* last created closure with this prototype */
struct TString *source; /* used for debug information */
struct GCObject *gclist;
} Proto;
struct UpVal;
struct CClosure {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char nupvalues;
struct GCObject *gclist;
int (*f)(struct lua_State *);
struct TValue upvalue[1]; /* list of upvalues */
};
struct LClosure {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char nupvalues;
struct GCObject *gclist;
struct Proto *p;
struct UpVal *upvals[1]; /* list of upvalues */
};
union Closure {
struct CClosure c;
struct LClosure l;
};
union TKey {
struct {
union Value value_;
int tt_;
int next; /* for chaining (offset for next node) */
} nk;
struct TValue tvk;
};
struct Node {
struct TValue i_val;
union TKey i_key;
};
struct Table {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char flags; /* 1<<p means tagmethod(p) is not present */
unsigned char lsizenode; /* log2 of size of 'node' array */
unsigned int sizearray; /* size of 'array' array */
struct TValue *array; /* array part */
struct Node *node;
struct Node *lastfree; /* any free position is before this position */
struct Table *metatable;
struct GCObject *gclist;
char *ravi_data;
enum ravitype_t ravi_array_type; /* RAVI specialization */
unsigned int ravi_array_len; /* RAVI len specialization */
unsigned int ravi_array_size; /* RAVI len specialization */
};
struct Mbuffer {
char *buffer;
unsigned long long n;
unsigned long long buffsize;
};
struct stringtable {
struct TString **hash;
int nuse; /* number of elements */
int size;
};
struct lua_Debug;
typedef long long ptrdiff_t;
typedef ptrdiff_t lua_KContext;
typedef int (*lua_KFunction)(struct lua_State *L, int status, lua_KContext ctx);
typedef void *(*lua_Alloc)(void *ud, void *ptr, unsigned long long osize,
unsigned long long nsize);
typedef void (*lua_Hook)(struct lua_State *L, struct lua_Debug *ar);
struct CallInfoL { /* only for Lua functions */
struct TValue *base; /* base for this function */
const unsigned int *savedpc;
ptrdiff_t dummy;
};
struct CallInfoC { /* only for C functions */
lua_KFunction k; /* continuation in case of yields */
ptrdiff_t old_errfunc;
lua_KContext ctx; /* context info. in case of yields */
};
struct CallInfo {
struct TValue *func; /* function index in the stack */
struct TValue *top; /* top for this function */
struct CallInfo *previous, *next; /* dynamic call link */
union {
struct CallInfoL l;
struct CallInfoC c;
} u;
ptrdiff_t extra;
short nresults; /* expected number of results from this function */
unsigned char callstatus;
unsigned char jitstatus;
};
struct CallInfoLua {
struct TValue *func; /* function index in the stack */
struct TValue *top; /* top for this function */
struct CallInfo *previous, *next; /* dynamic call link */
struct CallInfoL l;
ptrdiff_t extra;
short nresults; /* expected number of results from this function */
unsigned char callstatus;
unsigned char jitstatus;
};
struct global_State;
struct lua_longjmp;
/*
** 'per thread' state
*/
struct lua_State {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char status;
struct TValue *top; /* first free slot in the stack */
struct global_State *l_G;
struct CallInfoLua *ci; /* call info for current function */
const unsigned int *oldpc; /* last pc traced */
struct TValue *stack_last; /* last free slot in the stack */
struct TValue *stack; /* stack base */
struct UpVal *openupval; /* list of open upvalues in this stack */
struct GCObject *gclist;
struct lua_State *twups; /* list of threads with open upvalues */
struct lua_longjmp *errorJmp; /* current error recover point */
struct CallInfo base_ci; /* CallInfo for first level (C calling Lua) */
lua_Hook hook;
ptrdiff_t errfunc; /* current error handling function (stack index) */
int stacksize;
int basehookcount;
int hookcount;
unsigned short nny; /* number of non-yieldable calls in stack */
unsigned short nCcalls; /* number of nested C calls */
unsigned char hookmask;
unsigned char allowhook;
};
#include "lua_hdr.h"
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 void luaF_close(struct lua_State *L, struct TValue *base);

@ -2,27 +2,28 @@
target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"
target triple = "i686-pc-windows-gnu"
%struct.Proto = type { %struct.GCObject*, i8, i8, i8, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, %struct.TValue*, i32*, %struct.Proto**, i32*, %struct.LocVar*, %struct.Upvaldesc*, %struct.LClosure*, %struct.TString*, %struct.GCObject* }
%struct.TValue = type { %union.Value, i32 }
%union.Value = type { i64 }
%struct.LocVar = type { %struct.TString*, i32, i32, i32 }
%struct.Upvaldesc = type { %struct.TString*, i8, i8 }
%struct.LClosure = type { %struct.GCObject*, i8, i8, i8, %struct.GCObject*, %struct.Proto*, [1 x %struct.UpVal*] }
%struct.UpVal = type opaque
%struct.TString = type { %struct.GCObject*, i8, i8, i8, i32, i64, %struct.TString* }
%struct.GCObject = type { %struct.GCObject*, i8, i8 }
%struct.lua_State = type { %struct.GCObject*, i8, i8, i8, %struct.TValue*, %struct.global_State*, %struct.CallInfoLua*, i32*, %struct.TValue*, %struct.TValue*, %struct.UpVal*, %struct.GCObject*, %struct.lua_State*, %struct.lua_longjmp*, %struct.CallInfo, void (%struct.lua_State*, %struct.lua_Debug*)*, i64, i32, i32, i32, i16, i16, i8, i8 }
%struct.global_State = type opaque
%struct.CallInfoLua = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %struct.CallInfoL, i64, i16, i8 }
%struct.CallInfoLua = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %struct.CallInfoL, i64, i16, i8, i8 }
%struct.CallInfoL = type { %struct.TValue*, i32*, i64 }
%struct.TValue = type { %union.Value, i32 }
%union.Value = type { i64 }
%struct.UpVal = type { %struct.TValue*, i64, %union.anon.0 }
%union.anon.0 = type { %struct.TValue }
%struct.lua_longjmp = type opaque
%struct.CallInfo = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %union.anon, i64, i16, i8 }
%struct.CallInfo = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %union.anon, i64, i16, i8, i8 }
%union.anon = type { %struct.CallInfoC }
%struct.CallInfoC = type { i32 (%struct.lua_State*, i32, i64)*, i64, i64 }
%struct.lua_Debug = type opaque
%struct.LClosure = type { %struct.GCObject*, i8, i8, i8, %struct.GCObject*, %struct.Proto*, [1 x %struct.UpVal*] }
%struct.Proto = type { %struct.GCObject*, i8, i8, i8, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, %struct.TValue*, i32*, %struct.Proto**, i32*, %struct.LocVar*, %struct.Upvaldesc*, %struct.LClosure*, %struct.TString*, %struct.GCObject*, %struct.RaviJITProto }
%struct.LocVar = type { %struct.TString*, i32, i32, i32 }
%struct.Upvaldesc = type { %struct.TString*, i32, i8, i8 }
%struct.TString = type { %struct.GCObject*, i8, i8, i8, i32, i64, %struct.TString* }
%struct.RaviJITProto = type { i8, i8*, i32 (%struct.lua_State*)* }
@.str = private unnamed_addr constant [12 x i8] c"value = %d\0A\00", align 1
@Proto = common global %struct.Proto zeroinitializer, align 4
; Function Attrs: nounwind
define void @testfunc(%struct.GCObject* nocapture readonly %obj) #0 {
@ -53,18 +54,18 @@ entry:
%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 !21
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 !21
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 !26
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 !27
%12 = load i32* %sizep, align 4, !tbaa !28
%cmp = icmp sgt i32 %12, 0
br i1 %cmp, label %if.then, label %if.end
@ -79,8 +80,8 @@ if.end: ; preds = %if.then, %entry
if.then11: ; preds = %if.end
%top12 = getelementptr inbounds %struct.CallInfoLua* %0, i32 0, i32 1
%13 = load %struct.TValue** %top12, align 4, !tbaa !28
store %struct.TValue* %13, %struct.TValue** %top, align 4, !tbaa !26
%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.end14: ; preds = %if.end, %if.then11
@ -108,24 +109,25 @@ attributes #2 = { "less-precise-fpmad"="false" "no-frame-pointer-elim"="true" "n
!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}
!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}
!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}
!21 = metadata !{i64 0, i64 4, metadata !16, i64 0, i64 4, metadata !16, i64 0, i64 4, metadata !22, i64 0, i64 4, metadata !16, i64 0, i64 8, metadata !23, i64 0, i64 8, metadata !24, i64 8, i64 4, metadata !22}
!22 = metadata !{metadata !11, metadata !11, i64 0}
!23 = metadata !{metadata !9, metadata !9, i64 0}
!24 = metadata !{metadata !25, metadata !25, i64 0}
!25 = metadata !{metadata !"double", metadata !4, i64 0}
!26 = metadata !{metadata !7, metadata !3, i64 8}
!27 = metadata !{metadata !20, metadata !11, i64 28}
!28 = metadata !{metadata !13, metadata !3, i64 4}
!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}

@ -1,285 +1,6 @@
extern int printf(const char *, ...);
struct GCObject {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
};
struct lua_State;
union Value {
struct GCObject *gc;
void *p;
int b;
int (*f)(struct lua_State *);
long long i;
double n;
};
struct TValue {
union Value value_;
int tt_;
};
struct TString {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char extra;
unsigned int hash;
unsigned long long len;
struct TString *hnext;
};
union MaxAlign {
double u;
void *s;
long long i;
long l;
};
union UTString {
union MaxAlign dummy;
struct TString tsv;
};
struct Udata {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char ttuv_; /* user value's tag */
struct Table *metatable;
unsigned long long len; /* number of bytes */
union Value user_; /* user value */
};
union UUdata {
union MaxAlign dummy; /* ensures maximum alignment for 'local' udata */
struct Udata uv;
};
struct Upvaldesc {
struct TString *name; /* upvalue name (for debug information) */
unsigned char instack; /* whether it is in stack */
unsigned char
idx; /* index of upvalue (in stack or in outer function's list) */
};
enum ravitype_t {
RAVI_TANY, /* Lua dynamic type */
RAVI_TNUMINT, /* integer number */
RAVI_TNUMFLT, /* floating point number */
RAVI_TARRAYINT, /* array of ints */
RAVI_TARRAYFLT, /* array of doubles */
RAVI_TFUNCTION,
RAVI_TTABLE,
RAVI_TSTRING,
RAVI_TNIL,
RAVI_TBOOLEAN
};
struct LocVar {
struct TString *varname;
int startpc; /* first point where variable is active */
int endpc; /* first point where variable is dead */
enum ravitype_t
ravi_type; /* RAVI type of the variable - RAVI_TANY if unknown */
};
struct Proto {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char numparams; /* number of fixed parameters */
unsigned char is_vararg;
unsigned char maxstacksize; /* maximum stack used by this function */
int sizeupvalues; /* size of 'upvalues' */
int sizek; /* size of 'k' */
int sizecode;
int sizelineinfo;
int sizep; /* size of 'p' */
int sizelocvars;
int linedefined;
int lastlinedefined;
struct TValue *k; /* constants used by the function */
unsigned int *code;
struct Proto **p; /* functions defined inside the function */
int *lineinfo; /* map from opcodes to source lines (debug information) */
struct LocVar *
locvars; /* information about local variables (debug information) */
struct Upvaldesc *upvalues; /* upvalue information */
struct LClosure *cache; /* last created closure with this prototype */
struct TString *source; /* used for debug information */
struct GCObject *gclist;
} Proto;
struct UpVal;
struct CClosure {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char nupvalues;
struct GCObject *gclist;
int (*f)(struct lua_State *);
struct TValue upvalue[1]; /* list of upvalues */
};
struct LClosure {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char nupvalues;
struct GCObject *gclist;
struct Proto *p;
struct UpVal *upvals[1]; /* list of upvalues */
};
union Closure {
struct CClosure c;
struct LClosure l;
};
union TKey {
struct {
union Value value_;
int tt_;
int next; /* for chaining (offset for next node) */
} nk;
struct TValue tvk;
};
struct Node {
struct TValue i_val;
union TKey i_key;
};
struct Table {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char flags; /* 1<<p means tagmethod(p) is not present */
unsigned char lsizenode; /* log2 of size of 'node' array */
unsigned int sizearray; /* size of 'array' array */
struct TValue *array; /* array part */
struct Node *node;
struct Node *lastfree; /* any free position is before this position */
struct Table *metatable;
struct GCObject *gclist;
char *ravi_data;
enum ravitype_t ravi_array_type; /* RAVI specialization */
unsigned int ravi_array_len; /* RAVI len specialization */
unsigned int ravi_array_size; /* RAVI len specialization */
};
struct Mbuffer {
char *buffer;
unsigned long long n;
unsigned long long buffsize;
};
struct stringtable {
struct TString **hash;
int nuse; /* number of elements */
int size;
};
struct lua_Debug;
typedef long long ptrdiff_t;
typedef ptrdiff_t lua_KContext;
typedef int (*lua_KFunction)(struct lua_State *L, int status, lua_KContext ctx);
typedef void *(*lua_Alloc)(void *ud, void *ptr, unsigned long long osize,
unsigned long long nsize);
typedef void (*lua_Hook)(struct lua_State *L, struct lua_Debug *ar);
struct CallInfoL { /* only for Lua functions */
struct TValue *base; /* base for this function */
const unsigned int *savedpc;
ptrdiff_t dummy;
};
struct CallInfoC { /* only for C functions */
lua_KFunction k; /* continuation in case of yields */
ptrdiff_t old_errfunc;
lua_KContext ctx; /* context info. in case of yields */
};
struct CallInfo {
struct TValue *func; /* function index in the stack */
struct TValue *top; /* top for this function */
struct CallInfo *previous, *next; /* dynamic call link */
union {
struct CallInfoL l;
struct CallInfoC c;
} u;
ptrdiff_t extra;
short nresults; /* expected number of results from this function */
unsigned char callstatus;
unsigned char jitstatus;
};
struct CallInfoLua {
struct TValue *func; /* function index in the stack */
struct TValue *top; /* top for this function */
struct CallInfo *previous, *next; /* dynamic call link */
struct CallInfoL l;
ptrdiff_t extra;
short nresults; /* expected number of results from this function */
unsigned char callstatus;
unsigned char jitstatus;
};
struct global_State;
struct lua_longjmp;
/*
** 'per thread' state
*/
struct lua_State {
struct GCObject *next;
unsigned char tt;
unsigned char marked;
unsigned char status;
struct TValue *top; /* first free slot in the stack */
struct global_State *l_G;
struct CallInfoLua *ci; /* call info for current function */
const unsigned int *oldpc; /* last pc traced */
struct TValue *stack_last; /* last free slot in the stack */
struct TValue *stack; /* stack base */
struct UpVal *openupval; /* list of open upvalues in this stack */
struct GCObject *gclist;
struct lua_State *twups; /* list of threads with open upvalues */
struct lua_longjmp *errorJmp; /* current error recover point */
struct CallInfo base_ci; /* CallInfo for first level (C calling Lua) */
lua_Hook hook;
ptrdiff_t errfunc; /* current error handling function (stack index) */
int stacksize;
int basehookcount;
int hookcount;
unsigned short nny; /* number of non-yieldable calls in stack */
unsigned short nCcalls; /* number of nested C calls */
unsigned char hookmask;
unsigned char allowhook;
};
struct UpVal {
struct TValue *v; /* points to stack or to its own value */
unsigned long long refcount; /* reference counter */
union {
struct { /* (when open) */
struct UpVal *next; /* linked list */
int touched; /* mark to avoid cycles with dead threads */
} open;
struct TValue value; /* the value (when closed) */
} u;
};
#define rttype(o) ((o)->tt_)
#define BIT_ISCOLLECTABLE (1 << 6)
#define iscollectable(o) (rttype(o) & BIT_ISCOLLECTABLE)
#define upisopen(up) ((up)->v != &(up)->u.value)
#include "lua_hdr.h"
extern int printf(const char *, ...);
extern void luaC_upvalbarrier_ (struct lua_State *L, struct UpVal *uv);
void luaV_op_call(struct lua_State *L, struct LClosure *cl, struct TValue *ra, int b, int c) {

@ -2,27 +2,26 @@
target datalayout = "e-m:w-p:32:32-i64:64-f80:32-n8:16:32-S32"
target triple = "i686-pc-windows-gnu"
%struct.Proto = type { %struct.GCObject*, i8, i8, i8, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, %struct.TValue*, i32*, %struct.Proto**, i32*, %struct.LocVar*, %struct.Upvaldesc*, %struct.LClosure*, %struct.TString*, %struct.GCObject* }
%struct.TValue = type { %union.Value, i32 }
%union.Value = type { i64 }
%struct.LocVar = type { %struct.TString*, i32, i32, i32 }
%struct.Upvaldesc = type { %struct.TString*, i8, i8 }
%struct.LClosure = type { %struct.GCObject*, i8, i8, i8, %struct.GCObject*, %struct.Proto*, [1 x %struct.UpVal*] }
%struct.UpVal = type { %struct.TValue*, i64, %union.anon.0 }
%union.anon.0 = type { %struct.TValue }
%struct.TString = type { %struct.GCObject*, i8, i8, i8, i32, i64, %struct.TString* }
%struct.GCObject = type { %struct.GCObject*, i8, i8 }
%struct.lua_State = type { %struct.GCObject*, i8, i8, i8, %struct.TValue*, %struct.global_State*, %struct.CallInfoLua*, i32*, %struct.TValue*, %struct.TValue*, %struct.UpVal*, %struct.GCObject*, %struct.lua_State*, %struct.lua_longjmp*, %struct.CallInfo, void (%struct.lua_State*, %struct.lua_Debug*)*, i64, i32, i32, i32, i16, i16, i8, i8 }
%struct.global_State = type opaque
%struct.CallInfoLua = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %struct.CallInfoL, i64, i16, i8 }
%struct.CallInfoLua = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %struct.CallInfoL, i64, i16, i8, i8 }
%struct.CallInfoL = type { %struct.TValue*, i32*, i64 }
%struct.UpVal = type { %struct.TValue*, i64, %union.anon.0 }
%union.anon.0 = type { %struct.TValue }
%struct.TValue = type { %union.Value, i32 }
%union.Value = type { i64 }
%struct.GCObject = type { %struct.GCObject*, i8, i8 }
%struct.lua_longjmp = type opaque
%struct.CallInfo = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %union.anon, i64, i16, i8 }
%struct.CallInfo = type { %struct.TValue*, %struct.TValue*, %struct.CallInfo*, %struct.CallInfo*, %union.anon, i64, i16, i8, i8 }
%union.anon = type { %struct.CallInfoC }
%struct.CallInfoC = type { i32 (%struct.lua_State*, i32, i64)*, i64, i64 }
%struct.lua_Debug = type opaque
@Proto = common global %struct.Proto zeroinitializer, align 4
%struct.LClosure = type { %struct.GCObject*, i8, i8, i8, %struct.GCObject*, %struct.Proto*, [1 x %struct.UpVal*] }
%struct.Proto = type { %struct.GCObject*, i8, i8, i8, i8, i8, i32, i32, i32, i32, i32, i32, i32, i32, %struct.TValue*, i32*, %struct.Proto**, i32*, %struct.LocVar*, %struct.Upvaldesc*, %struct.LClosure*, %struct.TString*, %struct.GCObject*, %struct.RaviJITProto }
%struct.LocVar = type { %struct.TString*, i32, i32, i32 }
%struct.Upvaldesc = type { %struct.TString*, i32, i8, i8 }
%struct.TString = type { %struct.GCObject*, i8, i8, i8, i32, i64, %struct.TString* }
%struct.RaviJITProto = type { i8, i8*, i32 (%struct.lua_State*)* }
; Function Attrs: nounwind
define void @luaV_op_call(%struct.lua_State* %L, %struct.LClosure* nocapture readonly %cl, %struct.TValue* nocapture readonly %ra, i32 %b, i32 %c) #0 {

@ -1,4 +1,4 @@
setlocal
set PATH=%PATH%;"c:\Program Files (x86)\LLVM\bin"
clang -S -emit-llvm -O %1
clang -S -emit-llvm -O1 %1

@ -0,0 +1,13 @@
#include "lua_hdr.h"
extern int test(struct lua_State *L, int y);
extern int i;
int test(struct lua_State *L, int y) {
int x = L->stacksize;
y = x+i;
return y;
}
Loading…
Cancel
Save