[PATCH] D155818: [CloneFunction][DebugInfo] Clone DISubprogram's local types
David Blaikie via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 24 13:39:51 PDT 2023
dblaikie added a comment.
> Additionally, when tracking function-local types in the DICompileUnit (via retainedTypes or enums fields), it seems reasonable to track the clones as well.
Hmm, when do we have function-local types in the DICompileUnit list? I thought we always put those on the subprogram now?
================
Comment at: llvm/lib/Transforms/Utils/CloneFunction.cpp:299-307
+ auto It = VMap.MD().find(Type);
+
+ if (It != VMap.MD().end() && It->first != It->second)
+ TypesToAdd.push_back(It->second.get());
+ else if (It == VMap.MD().end()) {
+ Metadata *Cloned = MDNode::replaceWithDistinct(Type->clone());
+ TypesToAdd.push_back(Cloned);
----------------
maybe turn this into a lambda or helper function - since it's 10 lines that's repeated twice, by the looks of it? (can pass in the list to push back to so one pushes back to the enums, and the other pushes back to the types)
================
Comment at: llvm/lib/Transforms/Utils/CloneFunction.cpp:311-318
+ SmallVector<Metadata *> NewEnums(CU->getEnumTypes().begin(),
+ CU->getEnumTypes().end()),
+ NewTypes(CU->getRetainedTypes().begin(),
+ CU->getRetainedTypes().end());
+ NewEnums.append(EnumsToAdd);
+ NewTypes.append(TypesToAdd);
+ CU->replaceEnumTypes(MDNode::get(CU->getContext(), NewEnums));
----------------
Maybe this could be streamlined a bit too - maybe doesn't saves lines, but makes it easier to read?
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D155818/new/
https://reviews.llvm.org/D155818
More information about the llvm-commits
mailing list