diff --git a/llvm/include/llvm/Transforms/Scalar/JumpThreading.h b/llvm/include/llvm/Transforms/Scalar/JumpThreading.h index 3427f1be6c0c..7d32b8b98840 100644 --- a/llvm/include/llvm/Transforms/Scalar/JumpThreading.h +++ b/llvm/include/llvm/Transforms/Scalar/JumpThreading.h @@ -89,7 +89,8 @@ class JumpThreadingPass : public PassInfoMixin { #else SmallSet, 16> LoopHeaders; #endif - DenseMap> TapirTasks; + DenseMap, SmallPtrSet> + TapirTasks; unsigned BBDupThreshold; unsigned DefaultBBDupThreshold; diff --git a/llvm/lib/Transforms/Scalar/JumpThreading.cpp b/llvm/lib/Transforms/Scalar/JumpThreading.cpp index a96eb4e13e6f..e12b7fd140a6 100644 --- a/llvm/lib/Transforms/Scalar/JumpThreading.cpp +++ b/llvm/lib/Transforms/Scalar/JumpThreading.cpp @@ -451,6 +451,7 @@ bool JumpThreadingPass::runImpl(Function &F, TargetLibraryInfo *TLI_, << '\n'); LoopHeaders.erase(&BB); LVI->eraseBlock(&BB); + TapirTasks.erase(&BB); DeleteDeadBlock(&BB, DTU); Changed = true; continue; @@ -480,6 +481,7 @@ bool JumpThreadingPass::runImpl(Function &F, TargetLibraryInfo *TLI_, } while (Changed); LoopHeaders.clear(); + TapirTasks.clear(); return EverChanged; } diff --git a/llvm/test/Transforms/Tapir/jump-threading-tapir-vh.ll b/llvm/test/Transforms/Tapir/jump-threading-tapir-vh.ll new file mode 100644 index 000000000000..e3f997d405c0 --- /dev/null +++ b/llvm/test/Transforms/Tapir/jump-threading-tapir-vh.ll @@ -0,0 +1,28 @@ +; Check that jump threading releases value handles to basic blocks +; containing Tapir instructions. +; +; RUN: opt < %s -passes="cgscc(devirt<4>(function(jump-threading,simplifycfg)))" -S | FileCheck %s +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" +target triple = "x86_64-unknown-linux-gnu" + +define linkonce_odr void @_ZN4gbbs8nn_chain3HACINS_10MinLinkageINS_15symmetric_graphINS_16symmetric_vertexEjEENS_20SimilarityClusteringENS_12ActualWeightEEES4_jEEDaRNS3_IT0_T1_EERT_() personality ptr null { +entry: + unreachable + +pfor.body.entry.i.i.i: ; preds = %pfor.inc.i.i.i + reattach within none, label %pfor.inc.i.i.i + +pfor.inc.i.i.i: ; preds = %pfor.inc.i.i.i, %pfor.body.entry.i.i.i + detach within none, label %pfor.body.entry.i.i.i, label %pfor.inc.i.i.i +} + +; CHECK: define linkonce_odr void @_ZN4gbbs8nn_chain3HACINS_10MinLinkageINS_15symmetric_graphINS_16symmetric_vertexEjEENS_20SimilarityClusteringENS_12ActualWeightEEES4_jEEDaRNS3_IT0_T1_EERT_() +; CHECK: entry: +; CHECK-NEXT: unreachable +; CHECK-NOT: pfor.body.entry.i.i.i: +; CHECK-NOT: reattach +; CHECK-NOT: pfor.inc.i.i.i: +; CHECK-NOT: detach + +; uselistorder directives +uselistorder ptr null, { 1, 2, 0 }