2009-04-08 Zoltan Varga <vargaz@gmail.com>
authorZoltan Varga <vargaz@gmail.com>
Wed, 8 Apr 2009 14:53:08 +0000 (14:53 -0000)
committerZoltan Varga <vargaz@gmail.com>
Wed, 8 Apr 2009 14:53:08 +0000 (14:53 -0000)
* mini-llvm.c (mono_llvm_emit_method): Pass i1/i2 arguments as i4 since
JITted code depends on it.

svn path=/trunk/mono/; revision=131328

mono/mini/ChangeLog
mono/mini/mini-llvm.c

index db0832d7f85083a8712c710d81ad05c4411ab36a..551b14d9cdc011485d2307743c87f7be9e3d20b2 100644 (file)
@@ -1,3 +1,8 @@
+2009-04-08  Zoltan Varga  <vargaz@gmail.com>
+
+       * mini-llvm.c (mono_llvm_emit_method): Pass i1/i2 arguments as i4 since 
+       JITted code depends on it.
+
 2009-04-08  Raja R Harinath  <harinath@hurrynot.org>
 
        * aot-compiler.c: Use new MonoGenericParam accessors.
index 9954a7c8f7bdb300d7da8aeccbab76c769fdf2c9..2e2892ba25eca4ecad23a9078547a6ee472de2ff 100644 (file)
@@ -187,6 +187,22 @@ type_to_llvm_type (EmitContext *ctx, MonoType *t)
        }
 }
 
+static LLVMTypeRef
+type_to_llvm_arg_type (EmitContext *ctx, MonoType *t)
+{
+       LLVMTypeRef ptype = type_to_llvm_type (ctx, t);
+       
+       if (ptype == LLVMInt8Type () || ptype == LLVMInt16Type ()) {
+               /* 
+                * LLVM generates code which only sets the lower bits, while JITted
+                * code expects all the bits to be set.
+                */
+               ptype = LLVMInt32Type ();
+       }
+
+       return ptype;
+}
+
 static G_GNUC_UNUSED LLVMTypeRef
 llvm_type_to_stack_type (LLVMTypeRef type)
 {
@@ -482,7 +498,7 @@ sig_to_llvm_sig (EmitContext *ctx, MonoMethodSignature *sig, gboolean vretaddr)
        for (i = 0; i < sig->param_count; ++i) {
                if (MONO_TYPE_ISSTRUCT (sig->params [i]))
                        LLVM_FAILURE (ctx, "vtype param");
-               param_types [pindex ++] = type_to_llvm_type (ctx, sig->params [i]);
+               param_types [pindex ++] = type_to_llvm_arg_type (ctx, sig->params [i]);
        }
        CHECK_FAILURE (ctx);
 
@@ -1543,7 +1559,7 @@ mono_llvm_emit_method (MonoCompile *cfg)
                                        if (i == 0 && sig->hasthis)
                                                args [pindex] = convert (ctx, args [pindex], IntPtrType ());
                                        else
-                                               args [pindex] = convert (ctx, args [pindex], type_to_llvm_type (ctx, sig->params [i - sig->hasthis]));
+                                               args [pindex] = convert (ctx, args [pindex], type_to_llvm_arg_type (ctx, sig->params [i - sig->hasthis]));
 
                                        pindex ++;
                                        l = l->next;