Compiling the following:
struct b { template <typename c> void d(c e) { d(e); } }; void f() { b a; a.d(0); }
With clang -fsplit-dwarf-inlining -g -gsplit-dwarf -fdebug-info-for-profiling -O2 triggers assertion failures that the subprogram die should have already been created by getOrCreateSubprogramDIE. It appears to not be created because we skip that for split dwarf in some cases, so make sure we don't skip that when the -fdebug-info-for-profiling option is used.
Note: this fix only addresses one issue common to building this with either dwarf 4 or 5. There is a second crash here still present with dwarf 5.
Idle thoughts, not especially related to this patch:
This may highlight an interesting situation:
Currently gmlt + split-dwarf-inlining + fission => non-fission gmlt, because split-dwarf-inlining is essentially the gmlt-like data, kept in the object file. So if the only thing that's being fissioned into the dwo is gmlt data anyway, and the gmlt-like data is also going in the object file, why bother with the dwo gmlt data? But if debug-info-for-profiling makes for particularly larger debug info, then it could be reasonable to have gmlt + split-dwarf-inlining + fission + debug-info-for-profiling all active at once. (though, perhaps now we have a good way to turn fission off (-gno-split-dwarf) perhaps we could remove that quirk I added that caused gmlt + split-dwarf-inlining + fission not to compos, but overriding/disabling fission)
Might be interesting to measure object/executable size metrics for debug-info-for-profiling + gmlt and debug-info-for-profiling + gmlt + fission + split-dwarf-inlining. See how much obj/exe space is saved by that and whether it's worth supporting.