[llvm] r329644 - [PR16756] Use SSAUpdaterBulk in JumpThreading.

Mikhail Zolotukhin via llvm-commits llvm-commits at lists.llvm.org
Mon Apr 9 17:46:22 PDT 2018


Sorry about that, I reverted the patch in r329650 until I figure out the issue.

Michael

> On Apr 9, 2018, at 5:22 PM, Aleksey Shlyapnikov <alekseys at google.com> wrote:
> 
> Our Android and Windows bots are unhappy with these changes: http://lab.llvm.org:8011/builders/sanitizer-windows/builds/27045 <http://lab.llvm.org:8011/builders/sanitizer-windows/builds/27045> and http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/builds/9491 <http://lab.llvm.org:8011/builders/sanitizer-x86_64-linux-android/builds/9491>
> 
> On Mon, Apr 9, 2018 at 4:37 PM, Michael Zolotukhin via llvm-commits <llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>> wrote:
> Author: mzolotukhin
> Date: Mon Apr  9 16:37:37 2018
> New Revision: 329644
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=329644&view=rev <http://llvm.org/viewvc/llvm-project?rev=329644&view=rev>
> Log:
> [PR16756] Use SSAUpdaterBulk in JumpThreading.
> 
> Summary:
> SSAUpdater is a bottleneck in JumpThreading, and this patch improves the
> situation by using SSAUpdaterBulk instead.
> 
> Compile time impact: no noticable changes on CTMark, a big improvement
> on the test from PR16756.
> 
> Reviewers: dberlin, davide, MatzeB
> 
> Subscribers: llvm-commits, hiraditya
> 
> Differential Revision: https://reviews.llvm.org/D44282 <https://reviews.llvm.org/D44282>
> 
> Modified:
>     llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
> 
> Modified: llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=329644&r1=329643&r2=329644&view=diff <http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp?rev=329644&r1=329643&r2=329644&view=diff>
> ==============================================================================
> --- llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp (original)
> +++ llvm/trunk/lib/Transforms/Scalar/JumpThreading.cpp Mon Apr  9 16:37:37 2018
> @@ -66,6 +66,7 @@
>  #include "llvm/Transforms/Utils/BasicBlockUtils.h"
>  #include "llvm/Transforms/Utils/Cloning.h"
>  #include "llvm/Transforms/Utils/SSAUpdater.h"
> +#include "llvm/Transforms/Utils/SSAUpdaterBulk.h"
>  #include "llvm/Transforms/Utils/ValueMapper.h"
>  #include <algorithm>
>  #include <cassert>
> @@ -1989,9 +1990,13 @@ bool JumpThreadingPass::ThreadEdge(Basic
>    // now have to update all uses of the value to use either the original value,
>    // the cloned value, or some PHI derived value.  This can require arbitrary
>    // PHI insertion, of which we are prepared to do, clean these up now.
> -  SSAUpdater SSAUpdate;
> +  SSAUpdaterBulk SSAUpdate;
>    SmallVector<Use*, 16> UsesToRename;
> +
> +  unsigned VarNum = 0;
>    for (Instruction &I : *BB) {
> +    UsesToRename.clear();
> +
>      // Scan all uses of this instruction to see if it is used outside of its
>      // block, and if so, record them in UsesToRename.
>      for (Use &U : I.uses()) {
> @@ -2008,19 +2013,15 @@ bool JumpThreadingPass::ThreadEdge(Basic
>      // If there are no uses outside the block, we're done with this instruction.
>      if (UsesToRename.empty())
>        continue;
> +    SSAUpdate.AddVariable(VarNum, I.getName(), I.getType());
> 
> -    DEBUG(dbgs() << "JT: Renaming non-local uses of: " << I << "\n");
> -
> -    // We found a use of I outside of BB.  Rename all uses of I that are outside
> -    // its block to be uses of the appropriate PHI node etc.  See ValuesInBlocks
> -    // with the two values we know.
> -    SSAUpdate.Initialize(I.getType(), I.getName());
> -    SSAUpdate.AddAvailableValue(BB, &I);
> -    SSAUpdate.AddAvailableValue(NewBB, ValueMapping[&I]);
> -
> -    while (!UsesToRename.empty())
> -      SSAUpdate.RewriteUse(*UsesToRename.pop_back_val());
> -    DEBUG(dbgs() << "\n");
> +    // We found a use of I outside of BB - we need to rename all uses of I that
> +    // are outside its block to be uses of the appropriate PHI node etc.
> +    SSAUpdate.AddAvailableValue(VarNum, BB, &I);
> +    SSAUpdate.AddAvailableValue(VarNum, NewBB, ValueMapping[&I]);
> +    for (auto U : UsesToRename)
> +      SSAUpdate.AddUse(VarNum, U);
> +    VarNum++;
>    }
> 
>    // Ok, NewBB is good to go.  Update the terminator of PredBB to jump to
> @@ -2037,6 +2038,10 @@ bool JumpThreadingPass::ThreadEdge(Basic
>                       {DominatorTree::Insert, PredBB, NewBB},
>                       {DominatorTree::Delete, PredBB, BB}});
> 
> +  // Apply all updates we queued with DDT and get the updated Dominator Tree.
> +  DominatorTree *DT = &DDT->flush();
> +  SSAUpdate.RewriteAllUses(DT);
> +
>    // At this point, the IR is fully up to date and consistent.  Do a quick scan
>    // over the new instructions and zap any that are constants or dead.  This
>    // frequently happens because of phi translation.
> 
> 
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at lists.llvm.org <mailto:llvm-commits at lists.llvm.org>
> http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits <http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits>
> 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180409/4b5ed63f/attachment.html>


More information about the llvm-commits mailing list