[llvm] [Utils] Identity map module-level debug info on first use in CloneFunction* (PR #118627)

Felipe de Azevedo Piovezan via llvm-commits llvm-commits at lists.llvm.org
Tue Dec 17 09:50:39 PST 2024


================
@@ -322,16 +317,21 @@ void llvm::CloneFunctionInto(Function *NewFunc, const Function *OldFunc,
   DISubprogram *SPClonedWithinModule =
       CollectDebugInfoForCloning(*OldFunc, Changes, DIFinder);
 
-  ModuleLevelChanges =
-      BuildDebugInfoMDMap(VMap.MD(), Changes, DIFinder, SPClonedWithinModule);
+  MetadataSetTy IdentityMD;
+  FindDebugInfoToIdentityMap(IdentityMD, Changes, DIFinder,
+                             SPClonedWithinModule);
 
-  const auto RemapFlag = ModuleLevelChanges ? RF_None : RF_NoModuleLevelChanges;
+  // Current implementation always upgrades from local changes to module level
+  // changes due to the way metadata cloning is done. See
+  // BuildDebugInfoToIdentityMap for more details.
----------------
felipepiovezan wrote:

Also note how this comment reads: it talks about "upgrading local changes to module level changes", but there is nothing about the upgrade in the final code (as opposed to the  old code).  In other words, this comment is making a temporal reference to code that used to exist, which is not very helpful for readers.

We can phrase it as: "Cloning is always a Module level operation, since Metadata needs to be cloned".

https://github.com/llvm/llvm-project/pull/118627


More information about the llvm-commits mailing list