Commit 683623b
authored
Fix silent bad codegen VSD possible tailcall converted to normal call (#49256)
The problem was when a VSD interface call returning a multi-byte struct
in registers was initially considered to be a tailcall, but the tailcall
was abandoned in morph due to not enough stack space to store outgoing
arguments, in which case we create a new call return local to store the
return struct, and re-morph the call. In doing so, we forget that we had
already added VSD non-standard args, and re-add them, leaving the originally
added arg as a "normal" arg that shouldn't be there.
So, in summary, for a call A->B, to see this failure, we need:
1. The call is considered a potential tailcall (by the importer)
2. The call requires non-standard arguments that add call argument IR in
fgInitArgInfo() (e.g., VSD call -- in this case, a generic interface call)
3. We reject the tailcall in fgMorphPotentialTailCall() (e.g., not enough
incoming arg stack space in A to store B's outgoing args), in this case
because the first arg is a large struct. We can't reject it earlier,
due to things like address exposed locals -- we must get far enough
through the checks to have called fgInitArgInfo() to add the extra
non-standard arg.
4. B returns a struct in multiple registers (e.g., a 16-byte struct in
Linux x64 ABI)
The fix is to remove the previously-added non-standard VSD argument IR when
we are preparing to re-morph a call.
There was one other location that was already doing this. I'm a little
worried that there are other places where the non-standard added IR is
not being considered when we clear out the arg info before remorphing.
It seems like there is some risk here. Probably, we should consider a
better way of handling the non-standard arg IR given the need in some
cases to re-morph calls.
I commented out a few cases of:
```
assert(!fgCanFastTailCall(call, nullptr));
```
because this function can call `fgInitArgInfo` which can alter the IR.
That seems dangerous in an assert, which should have any side-effects
like modifying the IR.
Fixes #49078
No SPMI asm diffs.1 parent 2129ae9 commit 683623b
File tree
5 files changed
+169
-8
lines changed- src
- coreclr/jit
- tests/JIT/Regression/JitBlue/Runtime_49078
5 files changed
+169
-8
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1205 | 1205 | | |
1206 | 1206 | | |
1207 | 1207 | | |
| 1208 | + | |
| 1209 | + | |
| 1210 | + | |
| 1211 | + | |
| 1212 | + | |
| 1213 | + | |
| 1214 | + | |
| 1215 | + | |
| 1216 | + | |
| 1217 | + | |
| 1218 | + | |
| 1219 | + | |
| 1220 | + | |
| 1221 | + | |
| 1222 | + | |
| 1223 | + | |
| 1224 | + | |
| 1225 | + | |
| 1226 | + | |
| 1227 | + | |
| 1228 | + | |
| 1229 | + | |
| 1230 | + | |
| 1231 | + | |
| 1232 | + | |
| 1233 | + | |
| 1234 | + | |
| 1235 | + | |
| 1236 | + | |
| 1237 | + | |
| 1238 | + | |
| 1239 | + | |
1208 | 1240 | | |
1209 | 1241 | | |
1210 | 1242 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4548 | 4548 | | |
4549 | 4549 | | |
4550 | 4550 | | |
| 4551 | + | |
| 4552 | + | |
4551 | 4553 | | |
4552 | 4554 | | |
4553 | 4555 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2456 | 2456 | | |
2457 | 2457 | | |
2458 | 2458 | | |
| 2459 | + | |
| 2460 | + | |
| 2461 | + | |
2459 | 2462 | | |
2460 | 2463 | | |
2461 | 2464 | | |
| |||
6777 | 6780 | | |
6778 | 6781 | | |
6779 | 6782 | | |
| 6783 | + | |
| 6784 | + | |
| 6785 | + | |
6780 | 6786 | | |
6781 | 6787 | | |
6782 | 6788 | | |
| |||
8004 | 8010 | | |
8005 | 8011 | | |
8006 | 8012 | | |
8007 | | - | |
| 8013 | + | |
| 8014 | + | |
| 8015 | + | |
| 8016 | + | |
8008 | 8017 | | |
8009 | 8018 | | |
8010 | 8019 | | |
| |||
8015 | 8024 | | |
8016 | 8025 | | |
8017 | 8026 | | |
8018 | | - | |
8019 | | - | |
8020 | | - | |
8021 | | - | |
8022 | | - | |
| 8027 | + | |
8023 | 8028 | | |
8024 | 8029 | | |
8025 | 8030 | | |
| |||
8634 | 8639 | | |
8635 | 8640 | | |
8636 | 8641 | | |
8637 | | - | |
| 8642 | + | |
| 8643 | + | |
| 8644 | + | |
| 8645 | + | |
8638 | 8646 | | |
8639 | 8647 | | |
8640 | 8648 | | |
| |||
9136 | 9144 | | |
9137 | 9145 | | |
9138 | 9146 | | |
9139 | | - | |
| 9147 | + | |
9140 | 9148 | | |
9141 | 9149 | | |
9142 | 9150 | | |
| |||
Lines changed: 105 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
Lines changed: 14 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
0 commit comments