Skip to content

Commit

Permalink
[mono][jit] Fix the bblock check in the box+callvirt optimization. (#…
Browse files Browse the repository at this point in the history
…95500)

Fixes #95347.

Co-authored-by: Zoltan Varga <[email protected]>
  • Loading branch information
github-actions[bot] and vargaz authored Dec 6, 2023
1 parent 3e8927f commit 287e3e2
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 3 deletions.
5 changes: 2 additions & 3 deletions src/mono/mono/mini/method-to-ir.c
Original file line number Diff line number Diff line change
Expand Up @@ -9707,12 +9707,11 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
// callvirt instance ISomeIface::Method()
// TO
// call SomeStruct::Method()
guchar* callvirt_ip;
guint32 callvirt_proc_token;
if (!((cfg->compile_aot || cfg->compile_llvm) && !mono_class_is_def(klass)) && // we cannot devirtualize in AOT when using generics
next_ip < end &&
(callvirt_ip = il_read_callvirt (next_ip, end, &callvirt_proc_token)) &&
ip_in_bb (cfg, cfg->cbb, callvirt_ip) ) {
il_read_callvirt (next_ip, end, &callvirt_proc_token) &&
ip_in_bb (cfg, cfg->cbb, next_ip) ) {
MonoMethod* iface_method;
MonoMethodSignature* iface_method_sig;

Expand Down
16 changes: 16 additions & 0 deletions src/tests/JIT/Regression/JitBlue/Runtime_95347/Runtime_95347.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.

using System;
using Xunit;

public static class Runtime_95347
{
[Fact]
public static int Test()
{
object? n = "abcd";
var s = (n ?? false).ToString();
return (s == "abcd") ? 100 : -1;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<Optimize>True</Optimize>
</PropertyGroup>
<ItemGroup>
<Compile Include="$(MSBuildProjectName).cs" />
</ItemGroup>
</Project>

0 comments on commit 287e3e2

Please sign in to comment.