[llvm] [LLVM][AArch64]Use load/store with consecutive registers in SME2 or S… (PR #77665)

Momchil Velikov via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 17 05:11:16 PST 2024


================
@@ -3082,7 +3121,8 @@ bool AArch64FrameLowering::restoreCalleeSavedRegisters(
 
   computeCalleeSaveRegisterPairs(MF, CSI, TRI, RegPairs, hasFP(MF));
 
-  auto EmitMI = [&](const RegPairInfo &RPI) -> MachineBasicBlock::iterator {
+  auto EmitMI = [&](const RegPairInfo &RPI,
+                    bool *PtrueCreated) -> MachineBasicBlock::iterator {
----------------
momchil-velikov wrote:

Generally, as a recommendation for a good C++ style, when a pointer cannot be null, prefer to pass a reference, e.g. `bool &PtrueCreated`. And since we have a lambda here with default capture by reference, it is not very sensible to pass some of the contextual information via the capture and some via explicit parameters. So you can just do
```
  ...
  bool PtrueCreated = false;
  auto EmitMI = [&](const RegPairInfo &RPI)  -> MachineBasicBlock::iterator {
...
```

For extra C++ fancy style points you can even encapsulate the bool inside the lambda itself like
```
auto EmitMI = [&, PtrueCreated = false](const RegPairInfo &RPI) mutable -> MachineBasicBlock::iterator { ...
````

https://github.com/llvm/llvm-project/pull/77665


More information about the llvm-commits mailing list