Skip to content

Commit cfd15d5

Browse files
authored
[mono] Always store to allocas in OP_LLVM_OUTARG_VT (#64303)
OP_LLVM_OUTARG_VT will, for some argument passing conventions, create an alloca and mirror its source SSA value into this alloca. If such an OP_LLVM_OUTARG_VT is first encountered in a basic block that does not contain the definition of the SSA value being mirrored, then sibling basic blocks (e.g. a loop body that may sometimes be skipped) can use garbage data if they also have OP_LLVM_OUTARG_VT opcodes referring to the same SSA values. This commit works around this by unconditionally storing the source OP_LLVM_OUTARG_VT value into its associated alloca. The resulting IR would be a little easier to read if we eagerly stored to an alloca mirror exactly once at each value's definition, but that would require more work to implement. Fixes JIT/SIMD/VectorExp_ro/VectorExp_ro. See #64179.
1 parent b0de7ba commit cfd15d5

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

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

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7486,7 +7486,7 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
74867486
addresses [ins->dreg] = addresses [ins->sreg1];
74877487
} else {
74887488
if (!addresses [ins->sreg1]) {
7489-
addresses [ins->sreg1] = build_alloca (ctx, t);
7489+
addresses [ins->sreg1] = build_named_alloca (ctx, t, "llvm_outarg_vt");
74907490
g_assert (values [ins->sreg1]);
74917491
LLVMBuildStore (builder, convert (ctx, values [ins->sreg1], type_to_llvm_type (ctx, t)), addresses [ins->sreg1]);
74927492
addresses [ins->dreg] = addresses [ins->sreg1];
@@ -7496,6 +7496,11 @@ process_bb (EmitContext *ctx, MonoBasicBlock *bb)
74967496
LLVMValueRef v = LLVMBuildLoad (builder, addresses [ins->sreg1], "llvm_outarg_vt_copy");
74977497
LLVMBuildStore (builder, convert (ctx, v, type_to_llvm_type (ctx, t)), addresses [ins->dreg]);
74987498
} else {
7499+
if (values [ins->sreg1]) {
7500+
LLVMTypeRef src_t = LLVMTypeOf (values [ins->sreg1]);
7501+
LLVMValueRef dst = convert (ctx, addresses [ins->sreg1], LLVMPointerType (src_t, 0));
7502+
LLVMBuildStore (builder, values [ins->sreg1], dst);
7503+
}
74997504
addresses [ins->dreg] = addresses [ins->sreg1];
75007505
}
75017506
}

src/tests/issues.targets

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2803,9 +2803,6 @@
28032803
<ExcludeList Include="$(XunitTestBinBase)/JIT/HardwareIntrinsics/Arm/ArmBase/Yield_*/**">
28042804
<Issue>https://github.com/dotnet/runtime/issues/64179</Issue>
28052805
</ExcludeList>
2806-
<ExcludeList Include="$(XunitTestBinBase)/JIT/SIMD/VectorExp_*/**">
2807-
<Issue>https://github.com/dotnet/runtime/issues/64179</Issue>
2808-
</ExcludeList>
28092806
</ItemGroup>
28102807

28112808
<ItemGroup Condition="'$(RuntimeFlavor)' == 'mono' and ('$(RuntimeVariant)' == 'llvmfullaot' or '$(RuntimeVariant)' == 'llvmaot')">

0 commit comments

Comments
 (0)