[llvm] [AArch64] Codegen for AArch64 Return Address Signing Hardening (PR #176187)

Anatoly Trosinenko via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 9 09:50:23 PDT 2026


================
@@ -234,6 +238,18 @@ static void emitAUTCFI(MachineBasicBlock &MBB, MachineBasicBlock::iterator MBBI,
   }
 }
 
+static inline void emitMOV(MachineBasicBlock &MBB,
+                           MachineBasicBlock::iterator &MBBI, DebugLoc DL,
+                           const AArch64InstrInfo *TII, Register Dst,
+                           Register Src) {
+  assert(&MBB == MBBI->getParent());
+  BuildMI(MBB, MBBI, DL, TII->get(AArch64::ORRXrs), Dst)
+      .addReg(AArch64::XZR)
+      .addReg(Src)
+      .addImm(0)
+      .setMIFlag(MachineInstr::FrameDestroy);
----------------
atrosinenko wrote:

I would rather not hardcode the `FrameDestroy` flag in a function named `emitMOV` (i.e. in a top-level function not mentioning epilogues anyhow). You can probably `return` the builder object and call this function like this:
```cpp
emitMOV(MBB, MBBI, DL, TII, AArch64::X17, AArch64::LR)
    .setMIFlag(MachineInstr::FrameDestroy);
```
Or you could return the constructed `MachineInstr *` and call `setFlag` on it.

Or maybe duplicating `emitMOV` lambda would be easier.

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


More information about the llvm-commits mailing list