[llvm] Map byref types to the same type as the this argument so they are called using...
authorZoltan Varga <vargaz@gmail.com>
Sat, 16 Sep 2017 07:44:05 +0000 (03:44 -0400)
committerGitHub <noreply@github.com>
Sat, 16 Sep 2017 07:44:05 +0000 (03:44 -0400)
mono/mini/iltests.il
mono/mini/mini-llvm.c

index b2d92af2cc6213805c3944fc37174168b125aa99..b5796520341be55f2ba19929cf8b695cde1a2395 100644 (file)
@@ -3023,4 +3023,25 @@ L_3:
                ldc.i4.0
                ret
     }
+
+       .method public static bool llvm_regress_59436 () {
+               // Code size       41 (0x29)
+               .maxstack  3
+               .locals init (float64 V_0,
+                                         float64 V_1,
+                                         valuetype [mscorlib]System.Decimal V_2)
+               IL_0000:  ldc.r8         1
+               IL_0009:  stloc.0
+               IL_000a:  ldc.r8         2
+               IL_0013:  stloc.1
+               IL_0014:  ldloc.0
+               IL_0015:  newobj         instance void [mscorlib]System.Decimal::.ctor(float64)
+               IL_001a:  ldloca.s   V_2
+               IL_001c:  ldloc.1
+               IL_001d:  call     instance void [mscorlib]System.Decimal::.ctor(float64)
+               IL_0022:  ldloc.2
+               IL_0023:  call     bool [mscorlib]System.Decimal::op_LessThanOrEqual(valuetype [mscorlib]System.Decimal,
+                                                                                                                                                          valuetype [mscorlib]System.Decimal)
+               IL_0028:  ret
+       }
 }
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: