[lld] r259439 - Add command line option to disable ObjC category merging.

Pete Cooper via llvm-commits llvm-commits at lists.llvm.org
Mon Feb 1 15:56:23 PST 2016


Author: pete
Date: Mon Feb  1 17:56:23 2016
New Revision: 259439

URL: http://llvm.org/viewvc/llvm-project?rev=259439&view=rev
Log:
Add command line option to disable ObjC category merging.

This adds the no_objc_category_merging cmdline option which will
be used in an upcoming commit to disable the category optimizer.

It is on by default in ld64 so we match that here.

Test case will come soon with the patch to make use of this option.

Modified:
    lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h
    lld/trunk/lib/Driver/DarwinLdDriver.cpp
    lld/trunk/lib/Driver/DarwinLdOptions.td

Modified: lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h?rev=259439&r1=259438&r2=259439&view=diff
==============================================================================
--- lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h (original)
+++ lld/trunk/include/lld/ReaderWriter/MachOLinkingContext.h Mon Feb  1 17:56:23 2016
@@ -129,6 +129,8 @@ public:
   void setKeepPrivateExterns(bool v) { _keepPrivateExterns = v; }
   bool demangleSymbols() const { return _demangle; }
   void setDemangleSymbols(bool d) { _demangle = d; }
+  bool mergeObjCCategories() const { return _mergeObjCCategories; }
+  void setMergeObjCCategories(bool v) { _mergeObjCCategories = v; }
   /// Create file at specified path which will contain a binary encoding
   /// of all input and output file paths.
   std::error_code createDependencyFile(StringRef path);
@@ -427,6 +429,7 @@ private:
   bool _testingFileUsage;
   bool _keepPrivateExterns;
   bool _demangle;
+  bool _mergeObjCCategories = true;
   StringRef _bundleLoader;
   mutable std::unique_ptr<mach_o::ArchHandler> _archHandler;
   mutable std::unique_ptr<Writer> _writer;

Modified: lld/trunk/lib/Driver/DarwinLdDriver.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdDriver.cpp?rev=259439&r1=259438&r2=259439&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdDriver.cpp (original)
+++ lld/trunk/lib/Driver/DarwinLdDriver.cpp Mon Feb  1 17:56:23 2016
@@ -817,6 +817,10 @@ bool DarwinLdDriver::parse(llvm::ArrayRe
     ctx.setUndefinedMode(UndefMode);
   }
 
+  // Handle -no_objc_category_merging.
+  if (parsedArgs.getLastArg(OPT_no_objc_category_merging))
+    ctx.setMergeObjCCategories(false);
+
   // Handle -rpath <path>
   if (parsedArgs.hasArg(OPT_rpath)) {
     switch (ctx.outputMachOType()) {

Modified: lld/trunk/lib/Driver/DarwinLdOptions.td
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/lib/Driver/DarwinLdOptions.td?rev=259439&r1=259438&r2=259439&view=diff
==============================================================================
--- lld/trunk/lib/Driver/DarwinLdOptions.td (original)
+++ lld/trunk/lib/Driver/DarwinLdOptions.td Mon Feb  1 17:56:23 2016
@@ -68,6 +68,10 @@ def undefined : Separate<["-"], "undefin
                 MetaVarName<"<undefined>">,
                 HelpText<"Determines how undefined symbols are handled.">,
                 Group<grp_opts>;
+def no_objc_category_merging : Flag<["-"], "no_objc_category_merging">,
+     HelpText<"Disables the optimisation which merges Objective-C categories "
+              "on a class in to the class itself.">,
+     Group<grp_opts>;
 
 // main executable options
 def grp_main : OptionGroup<"opts">, HelpText<"MAIN EXECUTABLE OPTIONS">;




More information about the llvm-commits mailing list