[PATCH] D125335: Pass lamba to MachineCopyProp to determine which MI is treated as Copy instruction.

Xin Tong via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon May 16 14:28:06 PDT 2022


adriantong1024 added inline comments.


================
Comment at: llvm/lib/CodeGen/MachineCopyPropagation.cpp:298
+    if (UseCopyInstr || EnableCopyInstr) {
+      PredicateCopy = [](const MachineInstr &MI) {
+        const TargetInstrInfo *TII = MI.getMF()->getSubtarget().getInstrInfo();
----------------
craig.topper wrote:
> adriantong1024 wrote:
> > craig.topper wrote:
> > > craig.topper wrote:
> > > > Why do you need a lambda inside the pass? Can't you pass around the bool and TII? And have a static function that takes MI, TII, and the bool and does the right thing?
> > > Or make more of the static functions in the pass, member functions so you don't have to pass around TII and the bool/predicate.
> > Yes. I thought about it and that has the cost of passing 2 arguments around. while this has the cost of retrieving TII from MI. 
> I think the 2 arguments wins since the predicate function is an argument and you're already passing TII to every function that gets the predicate. So replacing the predicate with a bool doesn't change the number of arguments.
Sure. let me get rid of the predicate. Thanks for the suggestion.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D125335



More information about the llvm-commits mailing list