@@ -634,7 +634,7 @@ static Value *julia_to_address(
634634        return  p;
635635    }
636636
637-     Type *slottype = julia_struct_to_llvm (jvinfo.typ , NULL , NULL );
637+     Type *slottype = julia_struct_to_llvm (ctx,  jvinfo.typ , NULL , NULL );
638638    //  pass the address of an alloca'd thing, not a box
639639    //  since those are immutable.
640640    Value *slot = emit_static_alloca (ctx, slottype);
@@ -806,7 +806,7 @@ static jl_cgval_t emit_cglobal(jl_codectx_t &ctx, jl_value_t **args, size_t narg
806806    else  {
807807        rt = (jl_value_t *)jl_voidpointer_type;
808808    }
809-     Type *lrt = julia_type_to_llvm (rt);
809+     Type *lrt = julia_type_to_llvm (ctx,  rt);
810810
811811    interpret_symbol_arg (ctx, sym, args[1 ], " cglobal" false );
812812
@@ -1030,7 +1030,7 @@ static jl_cgval_t emit_llvmcall(jl_codectx_t &ctx, jl_value_t **args, size_t nar
10301030    for  (size_t  i = 0 ; i < nargt; ++i) {
10311031        jl_value_t  *tti = jl_svecref (tt,i);
10321032        bool  toboxed;
1033-         Type *t = julia_type_to_llvm (tti, &toboxed);
1033+         Type *t = julia_type_to_llvm (ctx,  tti, &toboxed);
10341034        argtypes.push_back (t);
10351035        if  (4  + i > nargs) {
10361036            jl_error (" Missing arguments to llvmcall!" 
@@ -1045,7 +1045,7 @@ static jl_cgval_t emit_llvmcall(jl_codectx_t &ctx, jl_value_t **args, size_t nar
10451045
10461046    Function *f;
10471047    bool  retboxed;
1048-     Type *rettype = julia_type_to_llvm (rtt, &retboxed);
1048+     Type *rettype = julia_type_to_llvm (ctx,  rtt, &retboxed);
10491049    if  (isString) {
10501050        //  Make sure to find a unique name
10511051        std::string ir_name;
@@ -1212,12 +1212,16 @@ class function_sig_t {
12121212    jl_unionall_t  *unionall_env; //  UnionAll environment for `at` and `rt`
12131213    size_t  nargs; //  number of actual arguments (can be different from the size of at when varargs)
12141214    size_t  isVa;
1215+     jl_codegen_params_t  *ctx;
12151216
1216-     function_sig_t (Type *lrt, jl_value_t  *rt, bool  retboxed, jl_svec_t  *at, jl_unionall_t  *unionall_env, size_t  nargs, size_t  isVa, CallingConv::ID cc, bool  llvmcall)
1217+     function_sig_t (Type *lrt, jl_value_t  *rt, bool  retboxed,
1218+             jl_svec_t  *at, jl_unionall_t  *unionall_env, size_t  nargs, size_t  isVa,
1219+             CallingConv::ID cc, bool  llvmcall,
1220+             jl_codegen_params_t  *ctx)
12171221      : fargt_vasig(NULL ), lrt(lrt), retboxed(retboxed),
12181222        prt (NULL ), sret(0 ), cc(cc), llvmcall(llvmcall),
12191223        functype(NULL ), at(at), rt(rt), unionall_env(unionall_env),
1220-         nargs(nargs), isVa(isVa)
1224+         nargs(nargs), isVa(isVa), ctx(ctx) 
12211225    {
12221226        err_msg = generate_func_sig ();
12231227        if  (err_msg.empty ())
@@ -1313,7 +1317,7 @@ std::string generate_func_sig()
13131317                }
13141318            }
13151319
1316-             t = julia_struct_to_llvm ( tti, unionall_env, &isboxed);
1320+             t = _julia_struct_to_llvm (ctx,  tti, unionall_env, &isboxed);
13171321            if  (isboxed)
13181322                t = T_prjlvalue;
13191323            if  (t == NULL  || t == T_void) {
@@ -1415,6 +1419,7 @@ static std::pair<CallingConv::ID, bool> convert_cconv(jl_sym_t *lhd)
14151419
14161420static  const  std::string verify_ccall_sig (size_t  nccallargs, jl_value_t  *&rt, jl_value_t  *at,
14171421                                          jl_unionall_t  *unionall_env, jl_svec_t  *sparam_vals, const  char  *funcName,
1422+                                           jl_codegen_params_t  *ctx,
14181423                                          size_t  &nargt, bool  &isVa, Type *&lrt, bool  &retboxed, bool  &static_rt)
14191424{
14201425    assert (rt && !jl_is_abstract_ref_type (rt));
@@ -1426,7 +1431,7 @@ static const std::string verify_ccall_sig(size_t nccallargs, jl_value_t *&rt, jl
14261431        rt = (jl_value_t *)jl_any_type;
14271432    }
14281433
1429-     lrt = julia_struct_to_llvm ( rt, unionall_env, &retboxed);
1434+     lrt = _julia_struct_to_llvm (ctx,  rt, unionall_env, &retboxed);
14301435    if  (lrt == NULL )
14311436        return  " ccall: return type doesn't correspond to a C type" 
14321437    else  if  (retboxed)
@@ -1552,6 +1557,7 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
15521557            nccallargs, rt, at, unionall,
15531558            ctx.spvals_ptr  == NULL  ? ctx.linfo ->sparam_vals  : NULL ,
15541559            ctx.funcName .c_str (),
1560+             &ctx.emission_context ,
15551561            /*  outputs: */ 
15561562            nargt, isVa, lrt, retboxed, static_rt);
15571563    if  (!err.empty ()) {
@@ -1638,7 +1644,7 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
16381644            isboxed = false ;
16391645        }
16401646        else  {
1641-             largty = julia_struct_to_llvm (tti, unionall, &isboxed);
1647+             largty = julia_struct_to_llvm (ctx,  tti, unionall, &isboxed);
16421648        }
16431649        if  (isboxed) {
16441650            ary = boxed (ctx, argv[0 ]);
@@ -1808,7 +1814,7 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
18081814    }
18091815
18101816    function_sig_t  sig (lrt, rt, retboxed, (jl_svec_t *)at, unionall, nccallargs,
1811-                        isVa, cc, llvmcall);
1817+                        isVa, cc, llvmcall, &ctx. emission_context );
18121818    jl_cgval_t  retval = sig.emit_a_ccall (
18131819            ctx,
18141820            symarg,
@@ -2055,7 +2061,7 @@ jl_cgval_t function_sig_t::emit_a_ccall(
20552061        }
20562062    }
20572063    else  {
2058-         Type *jlrt = julia_type_to_llvm (rt, &jlretboxed); //  compute the real "julian" return type and compute whether it is boxed
2064+         Type *jlrt = julia_type_to_llvm (ctx,  rt, &jlretboxed); //  compute the real "julian" return type and compute whether it is boxed
20592065        if  (jlretboxed) {
20602066            jlrt = T_prjlvalue;
20612067        }
0 commit comments