[llvm] Map byref types to the same type as the this argument so they are called using...
[mono.git] / mono / mini / mini-llvm.c
index 8a0b622da281a5d7917e799a7f247b72fc70c0b3..0b996be7f1838ee8a684725105b03d1d60afe7b5 100644 (file)
@@ -467,6 +467,9 @@ create_llvm_type_for_type (MonoLLVMModule *module, MonoClass *klass)
 static LLVMTypeRef
 type_to_llvm_type (EmitContext *ctx, MonoType *t)
 {
+       if (t->byref)
+               return ThisType ();
+
        t = mini_get_underlying_type (t);
 
        switch (t->type) {
@@ -1226,10 +1229,10 @@ sig_to_llvm_sig_no_cinfo (EmitContext *ctx, MonoMethodSignature *sig)
        int i, pindex;
        MonoType *rtype;
 
-       rtype = mini_get_underlying_type (sig->ret);
-       ret_type = type_to_llvm_type (ctx, rtype);
+       ret_type = type_to_llvm_type (ctx, sig->ret);
        if (!ctx_ok (ctx))
                return NULL;
+       rtype = mini_get_underlying_type (sig->ret);
 
        param_types = g_new0 (LLVMTypeRef, (sig->param_count * 8) + 3);
        pindex = 0;
@@ -1269,10 +1272,10 @@ sig_to_llvm_sig_full (EmitContext *ctx, MonoMethodSignature *sig, LLVMCallInfo *
        if (!cinfo)
                return sig_to_llvm_sig_no_cinfo (ctx, sig);
 
-       rtype = mini_get_underlying_type (sig->ret);
-       ret_type = type_to_llvm_type (ctx, rtype);
+       ret_type = type_to_llvm_type (ctx, sig->ret);
        if (!ctx_ok (ctx))
                return NULL;
+       rtype = mini_get_underlying_type (sig->ret);
 
        switch (cinfo->ret.storage) {
        case LLVMArgVtypeInReg: