@@ -616,7 +616,7 @@ static void interpret_symbol_arg(jl_codectx_t &ctx, native_sym_arg_t &out, jl_va
616616            emit_cpointercheck (ctx, arg1, errmsg);
617617        }
618618        arg1 = update_julia_type (ctx, arg1, (jl_value_t *)jl_voidpointer_type);
619-         jl_ptr = emit_unbox (ctx, ctx.types ().T_size , arg1, (jl_value_t *)jl_voidpointer_type);
619+         jl_ptr = emit_unbox (ctx, ctx.types ().T_ptr , arg1, (jl_value_t *)jl_voidpointer_type);
620620    }
621621    else  {
622622        out.gcroot  = ptr;
@@ -696,7 +696,7 @@ static jl_cgval_t emit_cglobal(jl_codectx_t &ctx, jl_value_t **args, size_t narg
696696    else  {
697697        rt = (jl_value_t *)jl_voidpointer_type;
698698    }
699-     Type *lrt = ctx.types ().T_size ;
699+     Type *lrt = ctx.types ().T_ptr ;
700700    assert (lrt == julia_type_to_llvm (ctx, rt));
701701
702702    interpret_symbol_arg (ctx, sym, args[1 ], /* ccall=*/ false , false );
@@ -723,7 +723,6 @@ static jl_cgval_t emit_cglobal(jl_codectx_t &ctx, jl_value_t **args, size_t narg
723723        }
724724        else  /* if (ctx.emission_context.imaging) */ 
725725            res = runtime_sym_lookup (ctx, cast<PointerType>(getInt8PtrTy (ctx.builder .getContext ())), sym.f_lib , NULL , sym.f_name , ctx.f );
726-             res = ctx.builder .CreatePtrToInt (res, lrt);
727726        }
728727    }
729728
@@ -1462,14 +1461,14 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
14621461    (void )isVa; //  prevent compiler warning
14631462    if  (is_libjulia_func (jl_value_ptr)) {
14641463        ++CCALL_STAT (jl_value_ptr);
1465-         assert (retboxed ? lrt == ctx.types ().T_prjlvalue  : lrt == ctx.types ().T_size );
1464+         assert (retboxed ? lrt == ctx.types ().T_prjlvalue  : lrt == ctx.types ().T_ptr );
14661465        assert (!isVa && !llvmcall && nccallargs == 1 );
14671466        jl_value_t  *tti = jl_svecref (at, 0 );
14681467        Type *largty;
14691468        bool  isboxed;
14701469        if  (jl_is_abstract_ref_type (tti)) {
14711470            tti = (jl_value_t *)jl_voidpointer_type;
1472-             largty = ctx.types ().T_size ;
1471+             largty = ctx.types ().T_ptr ;
14731472            isboxed = false ;
14741473        }
14751474        else  {
@@ -1482,7 +1481,6 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
14821481        }
14831482        else  {
14841483            retval = emit_unbox (ctx, largty, argv[0 ], tti);
1485-             retval = emit_inttoptr (ctx, retval, ctx.types ().T_pjlvalue );
14861484        }
14871485        //  retval is now an untracked jl_value_t*
14881486        if  (retboxed)
@@ -1561,9 +1559,7 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
15611559        assert (lrt == ctx.types ().T_size );
15621560        assert (!isVa && !llvmcall && nccallargs == 0 );
15631561        JL_GC_POP ();
1564-         return  mark_or_box_ccall_result (ctx,
1565-             ctx.builder .CreatePtrToInt (get_current_ptls (ctx), lrt),
1566-             retboxed, rt, unionall, static_rt);
1562+         return  mark_or_box_ccall_result (ctx, get_current_ptls (ctx), retboxed, rt, unionall, static_rt);
15671563    }
15681564    else  if  (is_libjulia_func (jl_threadid)) {
15691565        ++CCALL_STAT (jl_threadid);
@@ -1683,29 +1679,27 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
16831679    }
16841680    else  if  (is_libjulia_func (jl_string_ptr)) {
16851681        ++CCALL_STAT (jl_string_ptr);
1686-         assert (lrt == ctx.types ().T_size );
1682+         assert (lrt == ctx.types ().T_ptr );
16871683        assert (!isVa && !llvmcall && nccallargs == 1 );
16881684        auto  obj = emit_bitcast (ctx, emit_pointer_from_objref (ctx, boxed (ctx, argv[0 ])),
16891685                                ctx.types ().T_pprjlvalue );
16901686        //  The inbounds gep makes it more clear to LLVM that the resulting value is not
16911687        //  a null pointer.
16921688        auto  strp = ctx.builder .CreateConstInBoundsGEP1_32 (ctx.types ().T_prjlvalue , obj, 1 );
1693-         strp = ctx.builder .CreatePtrToInt (strp, ctx.types ().T_size );
16941689        setName (ctx.emission_context , strp, " string_ptr" 
16951690        JL_GC_POP ();
16961691        return  mark_or_box_ccall_result (ctx, strp, retboxed, rt, unionall, static_rt);
16971692    }
16981693    else  if  (is_libjulia_func (jl_symbol_name)) {
16991694        ++CCALL_STAT (jl_symbol_name);
1700-         assert (lrt == ctx.types ().T_size );
1695+         assert (lrt == ctx.types ().T_ppint8 );
17011696        assert (!isVa && !llvmcall && nccallargs == 1 );
17021697        auto  obj = emit_bitcast (ctx, emit_pointer_from_objref (ctx, boxed (ctx, argv[0 ])),
17031698                                ctx.types ().T_pprjlvalue );
17041699        //  The inbounds gep makes it more clear to LLVM that the resulting value is not
17051700        //  a null pointer.
17061701        auto  strp = ctx.builder .CreateConstInBoundsGEP1_32 (
17071702            ctx.types ().T_prjlvalue , obj, (sizeof (jl_sym_t ) + sizeof (void *) - 1 ) / sizeof (void *));
1708-         strp = ctx.builder .CreatePtrToInt (strp, ctx.types ().T_size );
17091703        setName (ctx.emission_context , strp, " symbol_name" 
17101704        JL_GC_POP ();
17111705        return  mark_or_box_ccall_result (ctx, strp, retboxed, rt, unionall, static_rt);
@@ -1750,14 +1744,12 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
17501744        const  jl_cgval_t  &dst = argv[0 ];
17511745        const  jl_cgval_t  &src = argv[1 ];
17521746        const  jl_cgval_t  &n = argv[2 ];
1753-         Value *destp = emit_unbox (ctx, ctx.types ().T_size , dst, (jl_value_t *)jl_voidpointer_type);
1747+         Value *destp = emit_unbox (ctx, ctx.types ().T_ptr , dst, (jl_value_t *)jl_voidpointer_type);
17541748
17551749        ctx.builder .CreateMemCpy (
1756-                 emit_inttoptr (ctx,  destp,  getInt8PtrTy (ctx. builder . getContext ())) ,
1750+                 destp,
17571751                MaybeAlign (1 ),
1758-                 emit_inttoptr (ctx,
1759-                     emit_unbox (ctx, ctx.types ().T_size , src, (jl_value_t *)jl_voidpointer_type),
1760-                     getInt8PtrTy (ctx.builder .getContext ())),
1752+                 emit_unbox (ctx, ctx.types ().T_ptr , src, (jl_value_t *)jl_voidpointer_type),
17611753                MaybeAlign (1 ),
17621754                emit_unbox (ctx, ctx.types ().T_size , n, (jl_value_t *)jl_ulong_type),
17631755                false );
@@ -1770,11 +1762,11 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
17701762        const  jl_cgval_t  &dst = argv[0 ];
17711763        const  jl_cgval_t  &val = argv[1 ];
17721764        const  jl_cgval_t  &n = argv[2 ];
1773-         Value *destp = emit_unbox (ctx, ctx.types ().T_size , dst, (jl_value_t *)jl_voidpointer_type);
1765+         Value *destp = emit_unbox (ctx, ctx.types ().T_ptr , dst, (jl_value_t *)jl_voidpointer_type);
17741766        Value *val32 = emit_unbox (ctx, getInt32Ty (ctx.builder .getContext ()), val, (jl_value_t *)jl_uint32_type);
17751767        Value *val8 = ctx.builder .CreateTrunc (val32, getInt8Ty (ctx.builder .getContext ()), " memset_val" 
17761768        ctx.builder .CreateMemSet (
1777-             emit_inttoptr (ctx,  destp,  getInt8PtrTy (ctx. builder . getContext ())) ,
1769+             destp,
17781770            val8,
17791771            emit_unbox (ctx, ctx.types ().T_size , n, (jl_value_t *)jl_ulong_type),
17801772            MaybeAlign (1 )
@@ -1788,14 +1780,12 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
17881780        const  jl_cgval_t  &dst = argv[0 ];
17891781        const  jl_cgval_t  &src = argv[1 ];
17901782        const  jl_cgval_t  &n = argv[2 ];
1791-         Value *destp = emit_unbox (ctx, ctx.types ().T_size , dst, (jl_value_t *)jl_voidpointer_type);
1783+         Value *destp = emit_unbox (ctx, ctx.types ().T_ptr , dst, (jl_value_t *)jl_voidpointer_type);
17921784
17931785        ctx.builder .CreateMemMove (
1794-                 emit_inttoptr (ctx,  destp,  getInt8PtrTy (ctx. builder . getContext ())) ,
1786+                 destp,
17951787                MaybeAlign (0 ),
1796-                 emit_inttoptr (ctx,
1797-                     emit_unbox (ctx, ctx.types ().T_size , src, (jl_value_t *)jl_voidpointer_type),
1798-                     getInt8PtrTy (ctx.builder .getContext ())),
1788+                 emit_unbox (ctx, ctx.types ().T_ptr , src, (jl_value_t *)jl_voidpointer_type),
17991789                MaybeAlign (0 ),
18001790                emit_unbox (ctx, ctx.types ().T_size , n, (jl_value_t *)jl_ulong_type),
18011791                false );
@@ -1999,7 +1989,7 @@ jl_cgval_t function_sig_t::emit_a_ccall(
19991989        ++LiteralCCalls;
20001990        null_pointer_check (ctx, symarg.jl_ptr , nullptr );
20011991        Type *funcptype = PointerType::get (functype, 0 );
2002-         llvmf = emit_inttoptr ( ctx,  symarg.jl_ptr , funcptype);
1992+         llvmf = ctx. builder . CreateBitCast ( symarg.jl_ptr , funcptype);
20031993    }
20041994    else  if  (symarg.fptr  != NULL ) {
20051995        ++LiteralCCalls;
0 commit comments