[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
Tue May 10 21:59:50 PDT 2022
adriantong1024 added inline comments.
================
Comment at: llvm/lib/Target/AArch64/AArch64TargetMachine.cpp:781
+ addPass(createMachineCopyPropagationPass([](const MachineInstr &MI) {
+ const TargetInstrInfo *TII = MI.getMF()->getSubtarget().getInstrInfo();
+ return TII->isCopyInstr(MI);
----------------
craig.topper wrote:
> adriantong1024 wrote:
> > craig.topper wrote:
> > > This feels a bit heavy to do for each instruction. The subtarget lookup has to query a hash table. MachineCopyProp already has TII. Why can't it call a virtual method on TII that AArch64 implements and have a default implementation that does whatever the previous behavior was.
> > >
> > > Or you could pass a bool to the MachineCopyPropagation that tells it to use TII->isCopyInstr() and default the bool to false for other targets.
> > It seems getting subtarget is returning a pointer to STI.
> >
> > https://github.com/llvm/llvm-project/blob/main/llvm/include/llvm/CodeGen/MachineFunction.h#L640
> So it does. I guess we call getSubtargetImpl and cache it earlier. Guess I forgot how that works.
>
> It's still very unusual to pass a lamba to a pass constructor. Are there other examples? We usually use TII to implement target behavior.
https://github.com/llvm/llvm-project/blob/main/llvm/lib/CodeGen/IfConversion.cpp#L2364 is one example. There are another example in CodeGen/ I could not find now.
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