Commit 4f0dfc1
committed
LifetimeDependenceScopeFixup: extend temporary stack allocations
When the source of a lifetime dependency is a stack-allocated address, extend
the stack allocation to cover all dependent uses.
This avoids miscompilations for "addressable" dependencies which arise in code
built with -enable-experimental-feature AddressableTypes or
AddressableParameters. It is always an error for SILGen to emit the alloc_stack
in such cases. Nonetheless, we want to handle these unexpected cases gracefully
in SIL as a diagnostic error rather than allowing a miscompile.
Fixes rdar://159680262 ([nonescapable] diagnose dependence on a
temporary copy of a global array)
(cherry picked from commit 7dfd105)1 parent 45a98a7 commit 4f0dfc1
File tree
5 files changed
+86
-34
lines changed- SwiftCompilerSources/Sources/Optimizer
- FunctionPasses
- PassManager
- Utilities
- test/SILOptimizer/lifetime_dependence
5 files changed
+86
-34
lines changedLines changed: 46 additions & 30 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
365 | 365 | | |
366 | 366 | | |
367 | 367 | | |
| 368 | + | |
368 | 369 | | |
369 | 370 | | |
370 | 371 | | |
| 372 | + | |
| 373 | + | |
371 | 374 | | |
372 | 375 | | |
373 | 376 | | |
374 | 377 | | |
375 | 378 | | |
376 | 379 | | |
377 | 380 | | |
| 381 | + | |
| 382 | + | |
378 | 383 | | |
379 | 384 | | |
380 | 385 | | |
381 | 386 | | |
382 | 387 | | |
383 | 388 | | |
384 | 389 | | |
| 390 | + | |
385 | 391 | | |
386 | 392 | | |
387 | 393 | | |
388 | 394 | | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
389 | 403 | | |
390 | 404 | | |
391 | 405 | | |
392 | 406 | | |
393 | 407 | | |
394 | 408 | | |
395 | | - | |
396 | | - | |
397 | | - | |
398 | | - | |
399 | | - | |
400 | | - | |
401 | | - | |
402 | | - | |
403 | | - | |
404 | | - | |
405 | | - | |
406 | | - | |
| 409 | + | |
| 410 | + | |
407 | 411 | | |
408 | | - | |
| 412 | + | |
409 | 413 | | |
410 | 414 | | |
411 | | - | |
| 415 | + | |
| 416 | + | |
412 | 417 | | |
413 | 418 | | |
414 | 419 | | |
415 | 420 | | |
416 | 421 | | |
417 | | - | |
418 | | - | |
| 422 | + | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
419 | 426 | | |
420 | | - | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
421 | 432 | | |
422 | 433 | | |
423 | 434 | | |
| |||
484 | 495 | | |
485 | 496 | | |
486 | 497 | | |
487 | | - | |
| 498 | + | |
488 | 499 | | |
489 | | - | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
490 | 503 | | |
491 | 504 | | |
| 505 | + | |
492 | 506 | | |
493 | 507 | | |
494 | 508 | | |
| |||
816 | 830 | | |
817 | 831 | | |
818 | 832 | | |
819 | | - | |
820 | | - | |
821 | | - | |
822 | | - | |
823 | | - | |
| 833 | + | |
| 834 | + | |
| 835 | + | |
824 | 836 | | |
825 | | - | |
826 | 837 | | |
827 | 838 | | |
828 | 839 | | |
| |||
868 | 879 | | |
869 | 880 | | |
870 | 881 | | |
| 882 | + | |
| 883 | + | |
| 884 | + | |
871 | 885 | | |
872 | 886 | | |
873 | 887 | | |
| |||
920 | 934 | | |
921 | 935 | | |
922 | 936 | | |
| 937 | + | |
923 | 938 | | |
924 | | - | |
925 | 939 | | |
926 | | - | |
| 940 | + | |
| 941 | + | |
| 942 | + | |
927 | 943 | | |
928 | 944 | | |
929 | 945 | | |
| |||
932 | 948 | | |
933 | 949 | | |
934 | 950 | | |
935 | | - | |
| 951 | + | |
936 | 952 | | |
937 | 953 | | |
938 | 954 | | |
939 | 955 | | |
940 | | - | |
| 956 | + | |
941 | 957 | | |
942 | | - | |
| 958 | + | |
943 | 959 | | |
944 | 960 | | |
945 | 961 | | |
| |||
Lines changed: 4 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
444 | 444 | | |
445 | 445 | | |
446 | 446 | | |
| 447 | + | |
| 448 | + | |
| 449 | + | |
| 450 | + | |
447 | 451 | | |
448 | 452 | | |
449 | 453 | | |
| |||
Lines changed: 23 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
381 | 381 | | |
382 | 382 | | |
383 | 383 | | |
| 384 | + | |
384 | 385 | | |
385 | | - | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
| 392 | + | |
| 393 | + | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
| 398 | + | |
| 399 | + | |
| 400 | + | |
| 401 | + | |
| 402 | + | |
| 403 | + | |
| 404 | + | |
| 405 | + | |
| 406 | + | |
| 407 | + | |
386 | 408 | | |
387 | 409 | | |
388 | 410 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
732 | 732 | | |
733 | 733 | | |
734 | 734 | | |
| 735 | + | |
| 736 | + | |
735 | 737 | | |
736 | 738 | | |
737 | 739 | | |
738 | 740 | | |
739 | 741 | | |
740 | 742 | | |
741 | 743 | | |
742 | | - | |
| 744 | + | |
743 | 745 | | |
744 | 746 | | |
745 | 747 | | |
| |||
Lines changed: 10 additions & 2 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
326 | 326 | | |
327 | 327 | | |
328 | 328 | | |
329 | | - | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
330 | 338 | | |
331 | 339 | | |
332 | | - | |
| 340 | + | |
333 | 341 | | |
0 commit comments