dzhidzhoev wrote:

> > So I was thinking in the opposite direction: should we force unique 
> > distinct definition DISubporgrams containing ODR-uniqued types, as well as 
> > it's done for declaration subprograms contained by ODR-uniqued types?
> 
> I'm suggesting more broadly: we should force-unique all DISubprograms (even 
> if they don't contain odr-uniqued types), by making them not distinct anymore 
> & generalizing the unquing infrastructure you quoted in langref.
> 
> This should address a broader class of problems - including, for instance, 
> LTO where a subprogram is inlined/out of line in multiple files.

In order to implement that, I'd suggest the following changes:
* Allow different llvm::Functions to refer to the same (distinct) DISubprogram 
(such case can pop up during LTO if subprograms are uniquied). I have sketched 
the implementation of that in https://github.com/llvm/llvm-project/pull/152680, 
https://github.com/llvm/llvm-project/pull/162852, 
https://github.com/llvm/llvm-project/pull/162854.
* Modify LLVM passes/DIBuilder interface so that (still distinct) subprograms 
are not modified, new subprograms are created when necessary.
* Modify CloneFunctionInto so that DISubprogram attached to a function is 
cloned only when explicitly requested, to reuse DISubprograms for function 
clones, and to establish one-to-one correspondence between abstract 
DISubprograms and abstract DIEs on the level of one CU/Module (when LTO is not 
enabled). It will also help to field-test 
https://github.com/llvm/llvm-project/pull/162854.
* Switch to uniqued DISubprograms. Merge retainedNodes of DISubprograms that 
are about to be uniqued with each other during LTO.
* Possibly, implement ODR-uniquing of DISubprograms based on linkageName during 
LTO.
* Attempt mergin https://github.com/llvm/llvm-project/pull/75385. Modify it in 
a way that local types are filtered out from DISubprogram's retainedNodes 
whenever DISubprogram is cloned (but the original DISubprogram is still used) 
to avoid ODR violations.

Does that sound reasonable? And will the performance regression caused by extra 
uniquing during LTO be acceptable?

https://github.com/llvm/llvm-project/pull/142166
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to