Conversation
DMD perf check
All measurements
4b61038 vs merge-base 6aba772 · about these metrics |
| else // MARS | ||
| { | ||
| // FIXME: is there a nicer place for this bool, outside the frontend? | ||
| bool hadCodegen; // whether it was codegen'd already |
There was a problem hiding this comment.
No idea if there is a better place, I'm not familiar with DMD enough.
| echo "Expected 1 '${mangled_sym}' symbol definition but got: ${num_typeinfo_syms}" | ||
| num_typeinfo_syms=$(nm --defined-only ${objfile} | (grep -F ${mangled_sym} || true) | wc -l) | ||
| if [[ "${num_typeinfo_syms}" -gt 1 ]]; then | ||
| echo "Expected at most 1 '${mangled_sym}' symbol definition but got: ${num_typeinfo_syms}" |
There was a problem hiding this comment.
This is still TODO. With the emission moving to the glue layer, this particular TypeInfo isn't emitted anymore. So my first attempt was to change the test, checking that no TypeInfos are defined at all in the object file for a basically-empty module, thus in a way also testing #23731 (the testcase there depends on Phobos and cannot be used as-is without dustmite reduction). But turns out that there's still a bunch of other TypeInfos being defined. :/
Allowing 0 occurrences of a particular TypeInfo here, as currently done, would make it hard to notice the test generally breaking at one point (e.g., reworked mangling or whatever). So this is just temporary, to get this test to pass for now. I guess I'll have to dig into the remaining TypeInfo definitions.
There was a problem hiding this comment.
Ah, these unexpected TypeInfo definitions come from -allinst leading to unexpected templates codegen. Without -allinst, there are no defined TypeInfos for this existing test case - but neither with master, so this test case isn't really suited for testing #23731.
| if nm --defined-only ${obj_decl} | grep -F TypeInfo; then | ||
| echo "Expected no non-TypeInfo_Class TypeInfo definitions along with the declarations!" | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
v2.113.0 additionally emitted all 3 other TypeInfos into the declarations object file (TypeInfo_{Struct,Interface,Enum}).
| if nm --defined-only ${obj_refs} | grep -E '__(Class|Interface)Z'; then | ||
| echo "Expected no TypeInfo_Class definitions for referencing object file!" | ||
| exit 1 | ||
| fi |
There was a problem hiding this comment.
v2.113.0 did NOT emit the TypeInfo_Interface, but the 3 other ones.
And also emitted these 3 TypeInfos for CTFE-only references - that's the biggest change here.
|
@ibuclaw: Do you already do something like this, or do you currently use |
|
I implement is_speculative in C++. Would love to remove it. Over the last fews years all attempts to let gcc discard unused symbols has resulted in undefined references at link-time. Some of these frontend changes might be the cause for that. |
…ng the needs-codegen check multiple times for ClassInfos and builtin TypeInfos]
|
LGTM. I wonder how much we can avoid the pessimistic |
Yeah, there might be room to avoid some of these after this, but I'm not really familiar with those frontend pieces. Maybe CTFE still requires some extra knowledge about the TypeInfos, potentially requiring extra semantic if the type declaration doesn't get sema3 in that compiler run.
AFAIK, it's only the
|
I don't think so,
ok
When called via |
Ah, I hadn't seen your #23287 yet - nice, thx for that, one less blocker. |
The main change is that TypeInfo emission is triggered from effective codegen in the glue layer only, independent from the AST nodes, and no TypeInfo declarations being appended to module members anymore (previously done as side effect of calling
getTypeInfoType()(!)).This primarily means that CTFE-only references of TypeInfos don't lead to the emission of these TypeInfos anymore, avoiding unexpected further link-time dependencies like #23731. And that comes naturally, without brittle
isSpeculativeType()logic.TypeInfo_Classinstances (for classes and interfaces,__ClassZ/__InterfaceZ) are still emitted once along with the class/interface declaration. All other (non-builtin, i.e., not druntime-defined) TypeInfos are now lazily emitted (when referenced from codegen somewhere) into one of the referencing object files being generated, per compiler run. This is different to LDC, which lazily emits them into every referencing object file (e.g., better inline-ability for code using TypeInfo indirections). (And don't worry, the duplicates are folded to a single symbol at link-time.)This adheres to the pay-as-you-go principle - if no codegen'd code needs a struct/interface/enum TypeInfo, it won't be emitted at all anymore (previously, as part of codegenning the type declaration).