[PATCH] D94547: [lld-macho] Run ObjCContractPass during LTO

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jan 14 00:49:11 PST 2021


fhahn added inline comments.


================
Comment at: llvm/lib/LTO/LTOBackend.cpp:285
 
+  MPM.addPass(createModuleToFunctionPassAdaptor(ObjCARCContractPass()));
   MPM.run(Mod, MAM);
----------------
The reason this is not added to all backend pipelines is (presumably) that we do not want to run this unnecessarily on platforms that do not support ObjC. I think we should add a new flag to `lto::Config`, so users can request it. But as I mentioned below, I think it would be better to do it at the beginning of the codegen pass pipeline.


================
Comment at: llvm/lib/LTO/LTOBackend.cpp:432
   }
 
   auto Stream = AddStream(Task);
----------------
lanza wrote:
> lanza wrote:
> > Sorry, to be clearer I think around here is the analogous point for the LTO.cpp pipeline. It directly precedes `addPassesToEmitFile` in the legacy impl.
> codegen and optimizations aren't directly coupled. You can codegen without optimizing and vice versa and run optimizations multiple times in the legacy impl. So this pass should stay coupled to codegen.
Yes, you don't necessarily have to run the `optimize` stage, but we still need to ensure the pass is run before codegen. So I think here would be a suitable place to just add the pass to `CodeGenPasses` (`LTOCodeGenerator.cpp` runs it just before calling `splitCodeGen` https://github.com/llvm/llvm-project/blob/master/llvm/lib/LTO/LTOCodeGenerator.cpp#L620)


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94547/new/

https://reviews.llvm.org/D94547



More information about the llvm-commits mailing list