Skip to content

Commit

Permalink
[llvm] When storing valuetypes received in registers to the stack, st…
Browse files Browse the repository at this point in the history
…ore only the value parts of the register, the upper bits might container garbage.
  • Loading branch information
vargaz committed Feb 7, 2016
1 parent 636c0c9 commit f666548
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
8 changes: 4 additions & 4 deletions mono/mini/mini-llvm.c
Original file line number Diff line number Diff line change
Expand Up @@ -2113,7 +2113,7 @@ emit_args_to_vtype (EmitContext *ctx, LLVMBuilderRef builder, MonoType *t, LLVMV
{
int j, size, nslots;

size = get_vtype_size (t);
size = mono_class_value_size (mono_class_from_mono_type (t), NULL);

if (MONO_CLASS_IS_SIMD (ctx->cfg, mono_class_from_mono_type (t))) {
address = LLVMBuildBitCast (ctx->builder, address, LLVMPointerType (LLVMInt8Type (), 0), "");
Expand All @@ -2129,6 +2129,9 @@ emit_args_to_vtype (EmitContext *ctx, LLVMBuilderRef builder, MonoType *t, LLVMV
int part_size = size > sizeof (gpointer) ? sizeof (gpointer) : size;
LLVMTypeRef part_type;

while (part_size != 1 && part_size != 2 && part_size != 4 && part_size < 8)
part_size ++;

if (ainfo->pair_storage [j] == LLVMArgNone)
continue;

Expand Down Expand Up @@ -4171,9 +4174,6 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
case LLVMArgVtypeAsScalar: {
LLVMTypeRef ret_type = LLVMGetReturnType (LLVMGetElementType (LLVMTypeOf (method)));
LLVMValueRef retval;
int size;

size = get_vtype_size (sig->ret);

g_assert (addresses [ins->sreg1]);

Expand Down
1 change: 1 addition & 0 deletions mono/mini/mini.h
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,7 @@ typedef enum {
LLVMArgInIReg,
/* Only in ainfo->pair_storage */
LLVMArgInFPReg,
/* Valuetype passed in 1-2 consecutive register */
LLVMArgVtypeInReg,
LLVMArgVtypeByVal,
LLVMArgVtypeRetAddr, /* On on cinfo->ret */
Expand Down

0 comments on commit f666548

Please sign in to comment.