Skip to content

Commit 45b6adf

Browse files
committed
[mono][jit] Fix the bblock check in the box+callvirt optimization.
Fixes #95347.
1 parent 60be20c commit 45b6adf

File tree

3 files changed

+26
-3
lines changed

3 files changed

+26
-3
lines changed

src/mono/mono/mini/method-to-ir.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9792,12 +9792,11 @@ mono_method_to_ir (MonoCompile *cfg, MonoMethod *method, MonoBasicBlock *start_b
97929792
// callvirt instance ISomeIface::Method()
97939793
// TO
97949794
// call SomeStruct::Method()
9795-
guchar* callvirt_ip;
97969795
guint32 callvirt_proc_token;
97979796
if (!((cfg->compile_aot || cfg->compile_llvm) && !mono_class_is_def(klass)) && // we cannot devirtualize in AOT when using generics
97989797
next_ip < end &&
9799-
(callvirt_ip = il_read_callvirt (next_ip, end, &callvirt_proc_token)) &&
9800-
ip_in_bb (cfg, cfg->cbb, callvirt_ip) ) {
9798+
il_read_callvirt (next_ip, end, &callvirt_proc_token) &&
9799+
ip_in_bb (cfg, cfg->cbb, next_ip) ) {
98019800
MonoMethod* iface_method;
98029801
MonoMethodSignature* iface_method_sig;
98039802

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Licensed to the .NET Foundation under one or more agreements.
2+
// The .NET Foundation licenses this file to you under the MIT license.
3+
4+
using System;
5+
using Xunit;
6+
7+
public static class Runtime_95347
8+
{
9+
[Fact]
10+
public static int Test()
11+
{
12+
object? n = "abcd";
13+
var s = (n ?? false).ToString();
14+
return (s == "abcd") ? 100 : -1;
15+
}
16+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
<PropertyGroup>
3+
<Optimize>True</Optimize>
4+
</PropertyGroup>
5+
<ItemGroup>
6+
<Compile Include="$(MSBuildProjectName).cs" />
7+
</ItemGroup>
8+
</Project>

0 commit comments

Comments
 (0)