[PATCH] D97039: [PowerPC] Enable redundant TOC save removal on AIX

Nemanja Ivanovic via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Feb 19 02:46:59 PST 2021


nemanjai added inline comments.


================
Comment at: llvm/lib/Target/PowerPC/PPCMIPeephole.cpp:229
   assert(TII->isTOCSaveMI(*MI) && "Expecting a TOC save instruction here");
-  assert(MF->getSubtarget<PPCSubtarget>().isELFv2ABI() &&
-         "TOC-save removal only supported on ELFv2");
-  PPCFunctionInfo *FI = MF->getInfo<PPCFunctionInfo>();
-
-  MachineBasicBlock *Entry = &MF->front();
-  uint64_t CurrBlockFreq = MBFI->getBlockFreq(MI->getParent()).getFrequency();
-
-  // If the block in which the TOC save resides is in a block that
-  // post-dominates Entry, or a block that is hotter than entry (keep in mind
-  // that early MachineLICM has already run so the TOC save won't be hoisted)
-  // we can just do the save in the prologue.
-  if (CurrBlockFreq > EntryFreq || MPDT->dominates(MI->getParent(), Entry))
-    FI->setMustSaveTOC(true);
-
-  // If we are saving the TOC in the prologue, all the TOC saves can be removed
-  // from the code.
-  if (FI->mustSaveTOC()) {
-    for (auto &TOCSave : TOCSaves)
-      TOCSave.second = false;
-    // Add new instruction to map.
-    TOCSaves[MI] = false;
-    return;
+  if (MF->getSubtarget<PPCSubtarget>().isELFv2ABI()) {
+    PPCFunctionInfo *FI = MF->getInfo<PPCFunctionInfo>();
----------------
Please add a comment as to why moving the TOC save to the prologue isn't to be done on AIX.


================
Comment at: llvm/lib/Target/PowerPC/PPCMIPeephole.cpp:483
+            (!MF->getSubtarget<PPCSubtarget>().isELFv2ABI() &&
+             !MF->getSubtarget<PPCSubtarget>().isAIXABI()))
           break;
----------------
On ELFv2, we obviously didn't bother with 32-bit mode because it doesn't really exist. However, on AIX we should probably handle 32-bit mode as well and do this for `PPC::STW` as well. Then of course, we'll need to update `PPCInstrInfo::isTOCSaveMI()`.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D97039/new/

https://reviews.llvm.org/D97039



More information about the llvm-commits mailing list