[PATCH] D44715: [MemorySSA] Fix exponential compile-time updating MemorySSA.

Eli Friedman via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 20 15:48:53 PDT 2018


efriedma created this revision.
efriedma added a reviewer: dberlin.
Herald added a subscriber: Prazek.

MemorySSAUpdater::getPreviousDefRecursive is a recursive algorithm, for each block, it computes the previous definition for each predecessor, then takes those definitions and combines them.  But currently it doesn't remember results which it already computed; this means it can visit the same block multiple times, which adds up to exponential time overall.

To fix this, this patch adds a cache.  If we computed the result for a block already, we don't need to visit it again because we'll come up with the same result. Well, unless we RAUW a MemoryPHI; in that case, the TrackingVH will be updated automatically.

I'm not sure this is the best fix, but it seems to work.

The testcase isn't really a test for the bug, but it adds coverage for the case where tryRemoveTrivialPhi erases an existing PHI node.  (It's hard to write a good regression test for a performance issue.)


Repository:
  rL LLVM

https://reviews.llvm.org/D44715

Files:
  include/llvm/Analysis/MemorySSAUpdater.h
  lib/Analysis/MemorySSAUpdater.cpp
  test/Transforms/GVNHoist/hoist-simplify-phi.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D44715.139203.patch
Type: text/x-patch
Size: 6986 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180320/0d5033a4/attachment.bin>


More information about the llvm-commits mailing list