Mercurial > projects > ldc
comparison gen/main.cpp @ 1482:d9c5f5a43403
Run `semantic3` on imported modules, and emit new symbols with
`available_externally` linkage. This allows the inliner to inline functions from
other modules while telling the code generator to ignore those functions (treat
them as declarations)
Still generates a few extra `TypeInfo`s and strings...
Disabled when generating debug info because I don't really understand it, and it
doesn't like this.
author | Frits van Bommel <fvbommel wxs.nl> |
---|---|
date | Sun, 07 Jun 2009 16:00:13 +0200 |
parents | a5526b7a5ae6 |
children | 7d3b47852a7a |
comparison
equal
deleted
inserted
replaced
1481:e0f03e11cdf8 | 1482:d9c5f5a43403 |
---|---|
33 #include "cond.h" | 33 #include "cond.h" |
34 | 34 |
35 #include "gen/logger.h" | 35 #include "gen/logger.h" |
36 #include "gen/linker.h" | 36 #include "gen/linker.h" |
37 #include "gen/irstate.h" | 37 #include "gen/irstate.h" |
38 #include "gen/optimizer.h" | |
38 #include "gen/toobj.h" | 39 #include "gen/toobj.h" |
39 #include "gen/metadata.h" | 40 #include "gen/metadata.h" |
40 #include "gen/passes/Passes.h" | 41 #include "gen/passes/Passes.h" |
41 | 42 |
42 #include "gen/cl_options.h" | 43 #include "gen/cl_options.h" |
809 * module being linked to may not have generated them, so if | 810 * module being linked to may not have generated them, so if |
810 * we inline functions from those modules, the symbols for them will | 811 * we inline functions from those modules, the symbols for them will |
811 * not be found at link time. | 812 * not be found at link time. |
812 */ | 813 */ |
813 if (!global.params.useArrayBounds && !global.params.useAssert) | 814 if (!global.params.useArrayBounds && !global.params.useAssert) |
815 #elif LLVM_REV >= 68940 | |
816 // This doesn't play nice with debug info at the moment | |
817 if (!global.params.symdebug && willInline()) | |
818 { | |
819 global.params.useAvailableExternally = true; | |
820 Logger::println("Running some extra semantic3's for inlining purposes"); | |
821 #else | |
822 // IN_LLVM, but available_externally not available yet. | |
823 if (false) | |
824 { | |
825 #endif | |
814 { | 826 { |
815 // Do pass 3 semantic analysis on all imported modules, | 827 // Do pass 3 semantic analysis on all imported modules, |
816 // since otherwise functions in them cannot be inlined | 828 // since otherwise functions in them cannot be inlined |
817 for (int i = 0; i < Module::amodules.dim; i++) | 829 for (int i = 0; i < Module::amodules.dim; i++) |
818 { | 830 { |
823 } | 835 } |
824 if (global.errors) | 836 if (global.errors) |
825 fatal(); | 837 fatal(); |
826 } | 838 } |
827 | 839 |
840 #if !IN_LLVM | |
828 for (int i = 0; i < modules.dim; i++) | 841 for (int i = 0; i < modules.dim; i++) |
829 { | 842 { |
830 m = (Module *)modules.data[i]; | 843 m = (Module *)modules.data[i]; |
831 if (global.params.verbose) | 844 if (global.params.verbose) |
832 printf("inline scan %s\n", m->toChars()); | 845 printf("inline scan %s\n", m->toChars()); |
833 m->inlineScan(); | 846 m->inlineScan(); |
834 } | 847 } |
848 #endif | |
835 } | 849 } |
836 if (global.errors) | 850 if (global.errors) |
837 fatal(); | 851 fatal(); |
838 #endif | |
839 | 852 |
840 // write module dependencies to file if requested | 853 // write module dependencies to file if requested |
841 if (global.params.moduleDepsFile != NULL) | 854 if (global.params.moduleDepsFile != NULL) |
842 { | 855 { |
843 assert (global.params.moduleDepsFile != NULL); | 856 assert (global.params.moduleDepsFile != NULL); |