Skip to content

Commit bfa0708

Browse files
authored
[mono][interp] Disable inlining of methods that always throw (#122587)
When inlining, we create a placeholder exit_bb that is branched to whenever the inlined method returns. When this bblock was not reachable, it was leading to some inconsistent CFG state. This is relatively easy to fix but, if exit_bb is dead, it means that the method is always throwing an exception. We shouldn't bother inlining such methods in the first place, since they are not part of hot code paths. Fixes #122529
1 parent feea419 commit bfa0708

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/mono/mono/mini/interp/transform.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8888,10 +8888,10 @@ generate_code (TransformData *td, MonoMethod *method, MonoMethodHeader *header,
88888888
memcpy (td->stack, exit_bb->stack_state, exit_bb->stack_height * sizeof(td->stack [0]));
88898889
td->sp = td->stack + exit_bb->stack_height;
88908890
}
8891-
// If exit_bb is not reached by any other bb in this method, just mark it as dead so the
8892-
// method that does the inlining no longer generates code for the following IL opcodes.
8891+
// If exit_bb is not reached by any other bb in this method, it means the method always
8892+
// throws an exception. Inlining it isn't beneficial since this shouldn't be perf sensitive code.
88938893
if (exit_bb->in_count == 0)
8894-
exit_bb->dead = TRUE;
8894+
INLINE_FAILURE;
88958895
else
88968896
exit_bb->emit_state = BB_STATE_EMITTING;
88978897
}

0 commit comments

Comments
 (0)