Skip to content

Commit

Permalink
[JumpThreading] Fix jump threading to remove pointers to deleted basi…
Browse files Browse the repository at this point in the history
…c blocks that contain Tapir instructions.
  • Loading branch information
neboat committed Oct 19, 2023
1 parent 3dd78f6 commit 6876173
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
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 }

0 comments on commit 6876173

Please sign in to comment.