[PATCH] D79660: [TRE] Allow elimination when the returned value is non-constant

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed May 13 14:10:07 PDT 2020


efriedma added a comment.

Can you add a few testcases for eliminating multiple tail calls?



================
Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:466
+  // other than the call we're removing.
+  PHINode *RetPN = nullptr;
+  PHINode *RetKnownPN = nullptr;
----------------
Maybe describe what specific instructions RetPN and RetKnownPN actually refer to?


================
Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:597
+    // can't know our return value at function entry.
+    RetPN->addIncoming(Constant::getNullValue(RetType), NewEntry);
+
----------------
Might as well use UndefValue::get here?


================
Comment at: llvm/lib/Transforms/Scalar/TailRecursionElimination.cpp:829
+      // uses of these PHI nodes, since they can only be used by themselves,
+      // but we hit an assertion that they still have uses if we don't.
+      BasicBlock *Entry = &F.getEntryBlock();
----------------
You can use dropAllReferences() to clear out the operands of an instruction before you erase it.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D79660





More information about the llvm-commits mailing list