[llvm] Use IntPtrType () for byref arguments instead of a pointer, the latter causes...
authorZoltan Varga <vargaz@gmail.com>
Tue, 17 Sep 2019 07:53:52 +0000 (03:53 -0400)
committerGitHub <noreply@github.com>
Tue, 17 Sep 2019 07:53:52 +0000 (03:53 -0400)
Commit migrated from https://github.com/mono/mono/commit/1031c4650df27fc77206c38a912228fb0862e198

src/mono/mono/mini/mini-llvm-cpp.cpp
src/mono/mono/mini/mini-llvm.c

index 08f04bd..33c0ad5 100644 (file)
@@ -51,7 +51,7 @@ void
 mono_llvm_dump_value (LLVMValueRef value)
 {
        /* Same as LLVMDumpValue (), but print to stdout */
-       outs () << (*unwrap<Value> (value));
+       outs () << (*unwrap<Value> (value)) << "\n";
        fflush (stdout);
 }
 
index 16b65eb..938efc7 100644 (file)
@@ -3578,10 +3578,17 @@ emit_entry_bb (EmitContext *ctx, LLVMBuilderRef builder)
                        /* The IR treats these as variables with addresses */
                        ctx->addresses [reg] = LLVMGetParam (ctx->lmethod, pindex);
                        break;
-               default:
-                       ctx->values [reg] = convert_full (ctx, ctx->values [reg], llvm_type_to_stack_type (cfg, type_to_llvm_type (ctx, ainfo->type)), type_is_unsigned (ctx, ainfo->type));
+               default: {
+                       LLVMTypeRef t;
+                       /* Needed to avoid phi argument mismatch errors since operations on pointers produce i32/i64 */
+                       if (ainfo->type->byref)
+                               t = IntPtrType ();
+                       else
+                               t = type_to_llvm_type (ctx, ainfo->type);
+                       ctx->values [reg] = convert_full (ctx, ctx->values [reg], llvm_type_to_stack_type (cfg, t), type_is_unsigned (ctx, ainfo->type));
                        break;
                }
+               }
        }
        g_free (names);