diff options
author | Zoltan Varga <vargaz@gmail.com> | 2017-09-16 10:44:05 +0300 |
---|---|---|
committer | Marek Safar <marek.safar@gmail.com> | 2017-10-17 10:21:39 +0300 |
commit | d092ad186ffae768279b092bdab513f65af2f7b2 (patch) | |
tree | dff81de670272328ac4212a6de8a5fc4be027bcf | |
parent | c6605763a36adbdffafcdc95721531e9679a6d95 (diff) |
[llvm] Map byref types to the same type as the this argument so they are called using the same signature if the this argument is passed explicitly. Fixes #59436. (#5572)
-rw-r--r-- | mono/mini/iltests.il | 21 | ||||
-rw-r--r-- | mono/mini/mini-llvm.c | 11 |
2 files changed, 28 insertions, 4 deletions
diff --git a/mono/mini/iltests.il b/mono/mini/iltests.il index 09c94309b70..97c4809e6a8 100644 --- a/mono/mini/iltests.il +++ b/mono/mini/iltests.il @@ -2896,4 +2896,25 @@ END: IL_0018: ldloc.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 + } } diff --git a/mono/mini/mini-llvm.c b/mono/mini/mini-llvm.c index 78b50ab033f..694189a96ac 100644 --- a/mono/mini/mini-llvm.c +++ b/mono/mini/mini-llvm.c @@ -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: |