Can DISubprogram be renamed?


I am afraid I am missing a big picture with debug info cloning.

Certainly after your patch (and possibly in some cases earlier):

Cloning: Reduce complexity of debug info cloning and fix correctness issue.

Commit r260791 contained an error in that it would introduce a cross-module

reference in the old module. It also introduced O(N^2) complexity in the

module cloner by requiring the entire module to be visited for each function.

Fix both of these problems by avoiding use of the CloneDebugInfoMetadata

function (which is only designed to do intra-module cloning) and cloning

function-attached metadata in the same way that we clone all other metadata.

Differential Revision:

During CloneFunctionInto we seem to create a new DISubprogram which still carries the name of the original function… which creates certain confusion with debugging scope.

Was it designed that way, or am I missing something here…

Thanks a lot.


I’d actually like to remove that functionality, as it is unused. See

Adrian’s change r266446 I think obsoletes that patch or at least makes it a lot simpler.


Will that take care of creating a properly named debug scope?

(“Properly” in this context == named after cloned destination…)

I don’t think so. My vague feeling is that only the caller of the CloneFunction function has all the context required to know if and how the subprogram should change (that includes not only names but e.g. parameters), so the caller should do that itself and add the new metadata to the value map.