Commit 20e9049
authored
[Serialization] Support loading template specializations lazily (llvm#119333)
Reland llvm#83237 --- (Original comments) Currently all the specializations of a template (including instantiation, specialization and partial specializations) will be loaded at once if we want to instantiate another instance for the template, or find instantiation for the template, or just want to complete the redecl chain. This means basically we need to load every specializations for the template once the template declaration got loaded. This is bad since when we load a specialization, we need to load all of its template arguments. Then we have to deserialize a lot of unnecessary declarations. For example, ``` // M.cppm export module M; export template <class T> class A {}; export class ShouldNotBeLoaded {}; export class Temp { A<ShouldNotBeLoaded> AS; }; // use.cpp import M; A<int> a; ``` We have a specialization ` A<ShouldNotBeLoaded>` in `M.cppm` and we instantiate the template `A` in `use.cpp`. Then we will deserialize `ShouldNotBeLoaded` surprisingly when compiling `use.cpp`. And this patch tries to avoid that. Given that the templates are heavily used in C++, this is a pain point for the performance. This patch adds MultiOnDiskHashTable for specializations in the ASTReader. Then we will only deserialize the specializations with the same template arguments. We made that by using ODRHash for the template arguments as the key of the hash table. To review this patch, I think `ASTReaderDecl::AddLazySpecializations` may be a good entry point.1 parent c00a708 commit 20e9049
File tree
29 files changed
+1645
-180
lines changed- clang
- include/clang
- AST
- Sema
- Serialization
- lib
- AST
- Sema
- Serialization
- test
- Modules
- OpenMP
- unittests/Serialization
- lldb/source/Plugins/ExpressionParser/Clang
29 files changed
+1645
-180
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
735 | 735 | | |
736 | 736 | | |
737 | 737 | | |
| 738 | + | |
738 | 739 | | |
739 | 740 | | |
740 | 741 | | |
| |||
775 | 776 | | |
776 | 777 | | |
777 | 778 | | |
778 | | - | |
| 779 | + | |
| 780 | + | |
| 781 | + | |
| 782 | + | |
779 | 783 | | |
780 | 784 | | |
781 | 785 | | |
782 | 786 | | |
783 | 787 | | |
784 | 788 | | |
| 789 | + | |
| 790 | + | |
| 791 | + | |
| 792 | + | |
| 793 | + | |
| 794 | + | |
785 | 795 | | |
786 | 796 | | |
787 | 797 | | |
| |||
796 | 806 | | |
797 | 807 | | |
798 | 808 | | |
799 | | - | |
800 | | - | |
801 | | - | |
802 | | - | |
803 | | - | |
804 | | - | |
805 | | - | |
806 | 809 | | |
807 | 810 | | |
808 | 811 | | |
| |||
2283 | 2286 | | |
2284 | 2287 | | |
2285 | 2288 | | |
2286 | | - | |
| 2289 | + | |
2287 | 2290 | | |
2288 | 2291 | | |
2289 | 2292 | | |
| |||
3033 | 3036 | | |
3034 | 3037 | | |
3035 | 3038 | | |
3036 | | - | |
| 3039 | + | |
3037 | 3040 | | |
3038 | 3041 | | |
3039 | 3042 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
155 | 170 | | |
156 | 171 | | |
157 | 172 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
97 | 97 | | |
98 | 98 | | |
99 | 99 | | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
100 | 106 | | |
101 | 107 | | |
102 | 108 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
733 | 733 | | |
734 | 734 | | |
735 | 735 | | |
| 736 | + | |
| 737 | + | |
| 738 | + | |
| 739 | + | |
| 740 | + | |
| 741 | + | |
| 742 | + | |
736 | 743 | | |
737 | 744 | | |
738 | 745 | | |
| |||
1502 | 1509 | | |
1503 | 1510 | | |
1504 | 1511 | | |
| 1512 | + | |
| 1513 | + | |
| 1514 | + | |
| 1515 | + | |
| 1516 | + | |
| 1517 | + | |
1505 | 1518 | | |
1506 | 1519 | | |
1507 | 1520 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
354 | 354 | | |
355 | 355 | | |
356 | 356 | | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
357 | 360 | | |
358 | 361 | | |
359 | 362 | | |
| |||
632 | 635 | | |
633 | 636 | | |
634 | 637 | | |
| 638 | + | |
| 639 | + | |
| 640 | + | |
| 641 | + | |
| 642 | + | |
| 643 | + | |
| 644 | + | |
| 645 | + | |
| 646 | + | |
| 647 | + | |
| 648 | + | |
| 649 | + | |
| 650 | + | |
| 651 | + | |
635 | 652 | | |
636 | 653 | | |
637 | 654 | | |
638 | | - | |
639 | | - | |
| 655 | + | |
| 656 | + | |
640 | 657 | | |
641 | 658 | | |
642 | 659 | | |
643 | | - | |
| 660 | + | |
644 | 661 | | |
645 | 662 | | |
646 | 663 | | |
647 | 664 | | |
648 | 665 | | |
| 666 | + | |
| 667 | + | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
649 | 672 | | |
650 | 673 | | |
651 | 674 | | |
| |||
678 | 701 | | |
679 | 702 | | |
680 | 703 | | |
| 704 | + | |
| 705 | + | |
| 706 | + | |
| 707 | + | |
| 708 | + | |
681 | 709 | | |
682 | 710 | | |
683 | 711 | | |
| |||
1419 | 1447 | | |
1420 | 1448 | | |
1421 | 1449 | | |
| 1450 | + | |
| 1451 | + | |
| 1452 | + | |
| 1453 | + | |
| 1454 | + | |
| 1455 | + | |
| 1456 | + | |
| 1457 | + | |
1422 | 1458 | | |
1423 | 1459 | | |
1424 | 1460 | | |
| |||
2076 | 2112 | | |
2077 | 2113 | | |
2078 | 2114 | | |
| 2115 | + | |
| 2116 | + | |
| 2117 | + | |
| 2118 | + | |
| 2119 | + | |
| 2120 | + | |
2079 | 2121 | | |
2080 | 2122 | | |
2081 | 2123 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
423 | 423 | | |
424 | 424 | | |
425 | 425 | | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
426 | 433 | | |
427 | 434 | | |
428 | 435 | | |
| |||
575 | 582 | | |
576 | 583 | | |
577 | 584 | | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
578 | 591 | | |
579 | 592 | | |
580 | 593 | | |
| |||
590 | 603 | | |
591 | 604 | | |
592 | 605 | | |
| 606 | + | |
593 | 607 | | |
594 | 608 | | |
595 | 609 | | |
| |||
619 | 633 | | |
620 | 634 | | |
621 | 635 | | |
| 636 | + | |
| 637 | + | |
| 638 | + | |
622 | 639 | | |
623 | 640 | | |
624 | 641 | | |
| |||
0 commit comments