Merge branch 'master' into config-checks-ipv6
[mono.git] / mono / mini / decompose.c
index b2ef584fb1e062a9d14531d01b2216c980823625..1c3060f162477cc8db01fbc0c64c6eb2c6f3ebbb 100644 (file)
@@ -1,5 +1,6 @@
-/*
- * decompose.c: Functions to decompose complex IR instructions into simpler ones.
+/**
+ * \file
+ * Functions to decompose complex IR instructions into simpler ones.
  *
  * Author:
  *   Zoltan Varga (vargaz@gmail.com)
@@ -19,9 +20,6 @@
 
 #ifndef DISABLE_JIT
 
-void mini_emit_stobj (MonoCompile *cfg, MonoInst *dest, MonoInst *src, MonoClass *klass, gboolean native);
-void mini_emit_initobj (MonoCompile *cfg, MonoInst *dest, const guchar *ip, MonoClass *klass);
-
 /*
  * Decompose complex long opcodes on 64 bit machines.
  * This is also used on 32 bit machines when using LLVM, so it needs to handle I/U correctly.
@@ -1510,10 +1508,13 @@ mono_decompose_array_access_opts (MonoCompile *cfg)
                                        break;
                                case OP_BOUNDS_CHECK:
                                        MONO_EMIT_NULL_CHECK (cfg, ins->sreg1);
-                                       if (COMPILE_LLVM (cfg))
-                                               MONO_EMIT_DEFAULT_BOUNDS_CHECK (cfg, ins->sreg1, ins->inst_imm, ins->sreg2, ins->flags & MONO_INST_FAULT);
-                                       else
+                                       if (COMPILE_LLVM (cfg)) {
+                                               int index2_reg = alloc_preg (cfg);
+                                               MONO_EMIT_NEW_UNALU (cfg, OP_SEXT_I4, index2_reg, ins->sreg2);
+                                               MONO_EMIT_DEFAULT_BOUNDS_CHECK (cfg, ins->sreg1, ins->inst_imm, index2_reg, ins->flags & MONO_INST_FAULT);
+                                       } else {
                                                MONO_ARCH_EMIT_BOUNDS_CHECK (cfg, ins->sreg1, ins->inst_imm, ins->sreg2);
+                                       }
                                        break;
                                case OP_NEWARR:
                                        if (cfg->opt & MONO_OPT_SHARED) {