You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
JIT: checked/release asm diff in GitHub_17777 #64793
One difference is the Checked build saves and restores all the callee-saved registers x19-x28 (and allocates arguments/locals to them, used as w19-w28), whereas Release doesn't save/restore or use them.
Unfortunately, even though it's a small test, it generates almost 300,000 arm64 instructions.
Actually, this does look like #64162, where we're overflowing the single allowed prolog IG.
We just need to increase this:
#ifdef TARGET_ARMARCH
// The only place where this limited instruction group size is a problem is
// in the prolog, where we only support a single instruction group. We should really fix that.
// ARM32 and ARM64 both can require a bigger prolog instruction group. One scenario is where
// a function uses all the incoming integer and single-precision floating-point arguments,
// and must store them all to the frame on entry. If the frame is very large, we generate
// ugly code like "movw r10, 0x488; add r10, sp; vstr s0, [r10]" for each store, which
// eats up our insGroup buffer.
#define SC_IG_BUFFER_SIZE (100 * sizeof(emitter::instrDesc) + 14 * SMALL_IDSC_SIZE)
#else // !TARGET_ARMARCH
#define SC_IG_BUFFER_SIZE (50 * sizeof(emitter::instrDesc) + 14 * SMALL_IDSC_SIZE)
#endif // !TARGET_ARMARCH
Perhaps some of the additional instructions generated recently for zero initialization, stack probing, etc., are eating up the static size that was available.
This number doesn't ensure the same number of instructions fit it both DEBUG and non-DEBUG builds, which is why DEBUG might not be failing.
Which gives (for this test case, for the per-test stats):
DEBUG build:
SC_IG_BUFFER_SIZE = 4800
SMALL_IDSC_SIZE per IG buffer = 300
instrDesc per IG buffer = 200
instrDescJmp per IG buffer = 85
instrDescCns per IG buffer = 150
instrDescDsp per IG buffer = 150
instrDescCnsDsp per IG buffer = 120
instrDescCGCA per IG buffer = 75
...
Max prolog instrDesc count: 83
Max prolog insGroup size : 2448
Release Build:
SC_IG_BUFFER_SIZE = 3200
SMALL_IDSC_SIZE per IG buffer = 400
instrDesc per IG buffer = 200
instrDescJmp per IG buffer = 66
instrDescCns per IG buffer = 133
instrDescDsp per IG buffer = 133
instrDescCnsDsp per IG buffer = 100
instrDescCGCA per IG buffer = 57
...
Max prolog instrDesc count: 83
Max prolog insGroup size : 1784
There is nothing scientific about this number, other than it fixes this problem, and leaves significant additional headroom for OSR or other scenarios.
What's the downside of doing this? Is it that we need a new IG per "superblock" (join-free span of blocks) during regular emission, so we may have a lot of wasted IG space in very branchy methods?
The downside is the single, global IG buffer is larger. So in the example above, we allocate 3200 bytes instead of 1712. If we only ever use 2000 bytes, we "waste" 1200 bytes.
All individual IGs are precisely sized when they are "saved" (when we reach a label, typically).
On the plus side, we will have fewer "extension" / "overflow" groups, because fewer blocks will reach the global buffer size.
Activity
BruceForstall commentedon Feb 4, 2022
The Release build is hitting this NO_WAY assert and dropping back to MinOpts:
with:
the igNum is an unsigned int, so we're not overflowing that. So maybe there's some corruption somewhere?
BruceForstall commentedon Feb 4, 2022
Actually, this does look like #64162, where we're overflowing the single allowed prolog IG.
We just need to increase this:
Perhaps some of the additional instructions generated recently for zero initialization, stack probing, etc., are eating up the static size that was available.
This number doesn't ensure the same number of instructions fit it both DEBUG and non-DEBUG builds, which is why DEBUG might not be failing.
AndyAyersMS commentedon Feb 5, 2022
This also impacts OSR on this test ... a fix would be nice.
BruceForstall commentedon Feb 7, 2022
Do you have any guidance on how many additional instructions OSR might require in the prolog, in the worst case?
BruceForstall commentedon Feb 10, 2022
Current IG buffer stats for ARM64:
DEBUG build:
Release build:
BruceForstall commentedon Feb 10, 2022
I propose to basically double the arm32/arm64 insGroup buffer, to:
Which gives (for this test case, for the per-test stats):
DEBUG build:
Release Build:
There is nothing scientific about this number, other than it fixes this problem, and leaves significant additional headroom for OSR or other scenarios.
AndyAyersMS commentedon Feb 10, 2022
What's the downside of doing this? Is it that we need a new IG per "superblock" (join-free span of blocks) during regular emission, so we may have a lot of wasted IG space in very branchy methods?
BruceForstall commentedon Feb 10, 2022
The downside is the single, global IG buffer is larger. So in the example above, we allocate 3200 bytes instead of 1712. If we only ever use 2000 bytes, we "waste" 1200 bytes.
All individual IGs are precisely sized when they are "saved" (when we reach a label, typically).
On the plus side, we will have fewer "extension" / "overflow" groups, because fewer blocks will reach the global buffer size.
AndyAyersMS commentedon Feb 10, 2022
Doesn't sound too bad then.
Increase arm32/arm64 maximum instruction group size
Increase arm32/arm64 maximum instruction group size (#65153)
BruceForstall commentedon Mar 1, 2022
Fixed by #65153