I’m investigating if it is possible to reduce debug info in a submodule that is extracted from a bigger one.
It would be nice if someone could help me figure out a couple of points in the work of
What our tool does with input module is it splits it into submodules. Each submodule contains an entry function, called functions and used global variables. Th several optimization passes are executed on each submodule.
One of them is
StripDeadDebugInfo pass. However, when I look in a submodule IR I see that not only compile units with entry function and dependenсies are included into debug metadata, but several other compile units.
I looked into implementation of StripDeadDebugInfo and saw two points that are unclear to me.
- First condition for living compile units is existence of DISubprograms that references to those units:
for (const DISubprogram *SP : F.subprograms()) if (SP->getUnit()) LiveCUs.insert(SP->getUnit());
The question here is: can we also check that there is a function definition that is present in current module and contains this DISubprogram?
- Another one place where extra compile units may be included is a check for presence of constant global variable expression in a compile unit:
if (DIG->getExpression() && DIG->getExpression()->isConstant()) LiveGVs.insert(DIG); ... if (LiveGVs.count(DIG)) LiveGlobalVariables.push_back(DIG); ... if (!LiveGlobalVariables.empty()) LiveCUs.insert(DIC);
What case is covered by this check for const global variable? May there be a situation when constant global var is defined in one translation unit, but used also in another one?
Or it is only for case when there is no functions in processed module?