runtime: RyuJIT: Methods that store to arguments can't be inlined
EDIT: Modified after figuring out the reason.
The following code wont be inlined because the arguments are modified inside the method body:
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void WildCopy(byte* dest, byte* src, byte* destEnd)
{
// This copy will use the same data that has already being copied as source
// It is more of a repeater than a copy per-se.
do
{
*((ulong*)dest) = *((ulong*)src);
dest += sizeof(ulong);
src += sizeof(ulong);
}
while (dest < destEnd);
}
However this code which clone the arguments is inlined without questions:
[MethodImpl(MethodImplOptions.AggressiveInlining)]
private static void WildCopy(byte* destPtr, byte* srcPtr, byte* destEndPtr)
{
byte* dest = destPtr;
byte* src = srcPtr;
byte* destEnd = destEndPtr;
// This copy will use the same data that has already being copied as source
// It is more of a repeater than a copy per-se.
do
{
*((ulong*)dest) = *((ulong*)src);
dest += sizeof(ulong);
src += sizeof(ulong);
}
while (dest < destEnd);
}
About this issue
- Original URL
- State: closed
- Created 8 years ago
- Comments: 15 (10 by maintainers)
Commits related to this issue
- WIP: Inline through starg Taking a stab at #6014 — committed to JosephTremoulet/coreclr by JosephTremoulet 8 years ago
- WIP: Inline through starg Taking a stab at #6014 — committed to JosephTremoulet/coreclr by JosephTremoulet 8 years ago
- Allow inlining when inlinee has `starg` The inliner's restriction that methods that make use of the `starg` opcode cannot be inlined is somewhat artificial. The comments indicate that the reason for... — committed to JosephTremoulet/coreclr by JosephTremoulet 8 years ago
- Allow inlining when inlinee has `starg` The inliner's restriction that methods that make use of the `starg` opcode cannot be inlined is somewhat artificial. The comments indicate that the reason for... — committed to JosephTremoulet/coreclr by JosephTremoulet 8 years ago
- Allow inlining when inlinee has `starg` The inliner's restriction that methods that make use of the `starg` opcode cannot be inlined is somewhat artificial. The comments indicate that the reason for... — committed to JosephTremoulet/coreclr by JosephTremoulet 8 years ago
- Allow inlining when inlinee has `starg` The inliner's restriction that methods that make use of the `starg` opcode cannot be inlined is somewhat artificial. The comments indicate that the reason for... — committed to JosephTremoulet/coreclr by JosephTremoulet 8 years ago
It is there in 1.1, along with the must-throw/no-return changes.
More trivial example:
JitDump:
This is actually pretty bad. All that is required to invalidate inlining a callee was that a parameter was killed. After removing InlineObservation::CALLEE_STORES_TO_ARGUMENT, I’m getting type mismatch TYP_REF != TYP_LONG.
I’ll check in a minute and let you know. However in that case, it should still be eligible for inlining as the pointers are passed by value. There is nothing that prevents the JIT to realize that.