Commit 3f922c3
authored
DeadArgumentElimination: Skip unprofitable single-call chains (#8072)
If a codebase has a long chain of single calls
a -> b -> c -> d
then we can end up in a very slow and unprofitable situation, removing
params from c's call to d, which then means c does not use some params,
and then we go back and so forth. Each step back requires a full scan of
the code. We could develop a more sophisticated IR to handle this, but it
would need to track that the local.get of the incoming param is only used
in an outgoing param, etc., which is not trivial, and these chains are
unprofitable in another way: single calls like this are inlined anyhow,
making this work redundant.
For simplicity, this PR detects the most obvious case of such a chain -
that an iteratiion of work only found a single single-caller call to remove
params from - and stops removing params from that point.
This makes this pass 30% faster on a large Dart testcase, which makes
-O3 9% faster. On other large wasm files I see much smaller benefits,
but it helps sometimes there too.
This is not truly NFC as while inlining will handle this case after, we do
alter the order a bit, leading to slightly different outputs sometimes. (The
changes are not better or worse, just noise.)1 parent 5efa505 commit 3f922c3
1 file changed
+68
-26
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
233 | 233 | | |
234 | 234 | | |
235 | 235 | | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
236 | 253 | | |
237 | 254 | | |
238 | 255 | | |
| |||
381 | 398 | | |
382 | 399 | | |
383 | 400 | | |
384 | | - | |
385 | | - | |
386 | | - | |
387 | | - | |
388 | | - | |
389 | | - | |
390 | | - | |
391 | | - | |
392 | | - | |
393 | | - | |
394 | | - | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
407 | | - | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
| 408 | + | |
| 409 | + | |
| 410 | + | |
| 411 | + | |
| 412 | + | |
| 413 | + | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
| 438 | + | |
| 439 | + | |
| 440 | + | |
| 441 | + | |
| 442 | + | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
408 | 446 | | |
409 | | - | |
410 | | - | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
| 451 | + | |
| 452 | + | |
411 | 453 | | |
412 | 454 | | |
413 | 455 | | |
| |||
0 commit comments