[lld] [lld-macho][ObjC] Implement category merging into base class (PR #92448)
Kyungwoo Lee via llvm-commits
llvm-commits at lists.llvm.org
Fri May 17 14:40:42 PDT 2024
================
@@ -1302,3 +1336,96 @@ void objc::mergeCategories() {
}
void objc::doCleanup() { ObjcCategoryMerger::doCleanup(); }
+
+void ObjcCategoryMerger::mergeCategoriesIntoBaseClass(
+ const Defined *baseClass, std::vector<InfoInputCategory> &categories) {
+ assert(categories.size() >= 1 && "Expected at least one category to merge");
+
+ // Collect all the info from the categories
+ ClassExtensionInfo extInfo(catLayout);
+ for (auto &catInfo : categories) {
+ parseCatInfoToExtInfo(catInfo, extInfo);
+ }
+
+ // Get metadata for the base class
+ Defined *metaRo = getClassRo(baseClass, /*getMetaRo=*/true);
+ ConcatInputSection *metaIsec = dyn_cast<ConcatInputSection>(metaRo->isec());
+ Defined *classRo = getClassRo(baseClass, /*getMetaRo=*/false);
+ ConcatInputSection *classIsec = dyn_cast<ConcatInputSection>(classRo->isec());
+
+ // Now collect the info from the base class from the various lists in the
+ // class metadata
+ parseProtocolListInfo(classIsec, roClassLayout.baseProtocolsOffset,
----------------
kyulee-com wrote:
Can you also align the order of processing fields consistently? Here is what I'm seeing:
- reading part: protocol, methods, properties (from meta to class)
- erasing part: methods, protocol, properties (from meta to class)
- writing part: methods, protocol, properties (from meta to class)
Does it make sense to handle them in a pair of meta and class, instead of handling all meta followed by class? That way, you might place the use/def chain back-to-back like `protoListSym`,
https://github.com/llvm/llvm-project/pull/92448
More information about the llvm-commits
mailing list