Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JumpThreading] Fix jump threading to remove pointers to deleted basi… #210

Merged
merged 1 commit into from
Oct 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion llvm/include/llvm/Transforms/Scalar/JumpThreading.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,8 @@ class JumpThreadingPass : public PassInfoMixin<JumpThreadingPass> {
#else
SmallSet<AssertingVH<const BasicBlock>, 16> LoopHeaders;
#endif
DenseMap<const BasicBlock *, SmallPtrSet<const BasicBlock *, 16>> TapirTasks;
DenseMap<AssertingVH<const BasicBlock>, SmallPtrSet<const BasicBlock *, 16>>
TapirTasks;

unsigned BBDupThreshold;
unsigned DefaultBBDupThreshold;
Expand Down
2 changes: 2 additions & 0 deletions llvm/lib/Transforms/Scalar/JumpThreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -480,6 +481,7 @@ bool JumpThreadingPass::runImpl(Function &F, TargetLibraryInfo *TLI_,
} while (Changed);

LoopHeaders.clear();
TapirTasks.clear();
return EverChanged;
}

Expand Down
28 changes: 28 additions & 0 deletions llvm/test/Transforms/Tapir/jump-threading-tapir-vh.ll
Original file line number Diff line number Diff line change
@@ -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<eager-inv>(jump-threading,simplifycfg<bonus-inst-threshold=1;no-forward-switch-cond;switch-range-to-icmp;no-switch-to-lookup;keep-loops;no-hoist-common-insts;no-sink-common-insts>)))" -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 }