[PATCH] Run objc-arc-contract when arc module flag is set

Steven Wu stevenwu at apple.com
Fri Feb 20 14:36:31 PST 2015

Hi dexonsmith, gottesmm,

objc-arc-contract is running unconditionally now in LTO. Since we
introduced the module flag for ARC in clang, we only need to run
that when the module flag is set.

This is relaying on the change in http://reviews.llvm.org/D7799
Not sure if I should add the pass to llc as well.



Index: lib/LTO/LTOCodeGenerator.cpp
--- lib/LTO/LTOCodeGenerator.cpp
+++ lib/LTO/LTOCodeGenerator.cpp
@@ -545,8 +545,10 @@
   formatted_raw_ostream Out(out);
   // If the bitcode files contain ARC code and were compiled with optimization,
-  // the ObjCARCContractPass must be run, so do it unconditionally here.
-  codeGenPasses.add(createObjCARCContractPass());
+  // the ObjCARCContractPass must be run, check the module flag to see if there
+  // is any file requires ARC
+  if (mergeModule->getModuleFlag("Objective-C ARC"))
+    codeGenPasses.add(createObjCARCContractPass());
   if (TargetMach->addPassesToEmitFile(codeGenPasses, Out,
                                       TargetMachine::CGFT_ObjectFile)) {

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D7800.20436.patch
Type: text/x-patch
Size: 788 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20150220/b357a9b9/attachment.bin>

More information about the llvm-commits mailing list