[PATCH] D118026: [RISCV] Improve the condition of hasRVVFrameObject.

Jianjian Guan via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Jan 24 03:34:29 PST 2022


jacquesguan created this revision.
jacquesguan added reviewers: HsiangKai, craig.topper, asb, frasercrmck, benshi001.
Herald added subscribers: VincentWu, luke957, achieveartificialintelligence, vkmr, evandro, luismarques, apazos, sameer.abuasal, s.egerton, Jim, benna, psnobl, jocewei, PkmX, the_o, brucehoult, MartinMosbeck, rogfer01, edward-jones, zzheng, jrtc27, kito-cheng, niosHD, sabuasal, simoncook, johnrusso, rbar, hiraditya.
jacquesguan requested review of this revision.
Herald added subscribers: llvm-commits, pcwang-thead, eopXD, MaskRay.
Herald added a project: LLVM.

Now the function hasRVVFrameObject is using hasVInstructions() as the return value. This patch changed it to two parts judgement. Firstly, check if there is any frame object that is scalable vector. If there is no scalable vector frame object, then check if there is any V instruction in the function.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D118026

Files:
  llvm/lib/Target/RISCV/RISCVFrameLowering.cpp


Index: llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
===================================================================
--- llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
+++ llvm/lib/Target/RISCV/RISCVFrameLowering.cpp
@@ -956,7 +956,27 @@
   // D103622.
   //
   // Refer to https://github.com/llvm/llvm-project/issues/53016.
-  return MF.getSubtarget<RISCVSubtarget>().hasVInstructions();
+
+  // Won't have RVV frame object without V/Zve* extensions.
+  if (!MF.getSubtarget<RISCVSubtarget>().hasVInstructions())
+    return false;
+
+  // If there is scalable vector, there must be RVV frame object.
+  const MachineFrameInfo &MFI = MF.getFrameInfo();
+  for (int I = 0, E = MFI.getObjectIndexEnd(); I != E; ++I)
+    if (MFI.getStackID(I) == TargetStackID::ScalableVector)
+      return true;
+
+  // If there is any RVV instruction in the function, there might be RVV frame
+  // object.
+  for (const auto &MBB : MF)
+    for (const auto &MI : MBB)
+      for (const auto &MO : MI.uses())
+        if (MO.isReg() && MO.getReg() == RISCV::VL)
+          return true;
+
+  // Otherwise, there should not be any RVV frame object.
+  return false;
 }
 
 // Not preserve stack space within prologue for outgoing variables when the


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D118026.402453.patch
Type: text/x-patch
Size: 1232 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220124/33294ceb/attachment.bin>


More information about the llvm-commits mailing list