[llvm] [CodeGen] Get stack alignment from TargetFrameLowering (NFCI) (PR #105477)

Christudasan Devadasan via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 21 01:01:52 PDT 2024


================
@@ -9133,9 +9133,10 @@ LegalizerHelper::lowerMemcpy(MachineInstr &MI, Register Dst, Register Src,
     // Don't promote to an alignment that would require dynamic stack
     // realignment.
     const TargetRegisterInfo *TRI = MF.getSubtarget().getRegisterInfo();
-    if (!TRI->hasStackRealignment(MF))
-      while (NewAlign > Alignment && DL.exceedsNaturalStackAlignment(NewAlign))
-        NewAlign = NewAlign.previous();
+    if (NewAlign > Alignment && !TRI->hasStackRealignment(MF)) {
+      const TargetFrameLowering *TFL = MF.getSubtarget().getFrameLowering();
+      NewAlign = std::min(NewAlign, TFL->getStackAlign());
+    }
----------------
cdevadas wrote:

There is a lot of code duplication. Why not move this code into a function and use it everywhere?

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


More information about the llvm-commits mailing list