[CaptureTracking] Do not check domination

For the CapturesBefore tracker, it is sufficient to check that
I can not reach BeforeHere. This does not necessarily require
that BeforeHere dominates I, it can also occur if the capture
happens on an entirely disjoint path.

This change was previously accepted in D90688, but had to be
reverted due to large compile-time impact in some cases: It
increases the number of reachability queries that are performed.

After recent changes, the compile-time impact is largely mitigated,
so I'm reapplying this patch. The remaining compile-time impact
is largely proportional to changes in code-size.
This commit is contained in:
Nikita Popov 2021-05-16 10:40:02 +02:00
parent aaf5fd4316
commit 6b8b43e7af
2 changed files with 3 additions and 9 deletions

View File

@ -143,14 +143,8 @@ namespace {
return !isPotentiallyReachableFromMany(Worklist, BB, nullptr, DT); return !isPotentiallyReachableFromMany(Worklist, BB, nullptr, DT);
} }
// If the value is defined in the same basic block as use and BeforeHere,
// there is no need to explore the use if BeforeHere dominates use.
// Check whether there is a path from I to BeforeHere. // Check whether there is a path from I to BeforeHere.
if (DT->dominates(BeforeHere, I) && return !isPotentiallyReachable(I, BeforeHere, nullptr, DT);
!isPotentiallyReachable(I, BeforeHere, nullptr, DT))
return true;
return false;
} }
bool captured(const Use *U) override { bool captured(const Use *U) override {

View File

@ -252,8 +252,8 @@ define void @capture_nopath_call(i1 %cond) {
; CHECK-NEXT: call void @accept_ptr(i8* [[DEST_I8]]) ; CHECK-NEXT: call void @accept_ptr(i8* [[DEST_I8]])
; CHECK-NEXT: ret void ; CHECK-NEXT: ret void
; CHECK: nocaptures: ; CHECK: nocaptures:
; CHECK-NEXT: call void @accept_ptr(i8* [[SRC_I8]]) #[[ATTR3]] ; CHECK-NEXT: [[DEST1:%.*]] = bitcast [16 x i8]* [[DEST]] to i8*
; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[DEST_I8]], i8* [[SRC_I8]], i64 16, i1 false) ; CHECK-NEXT: call void @accept_ptr(i8* [[DEST1]]) #[[ATTR3]]
; CHECK-NEXT: ret void ; CHECK-NEXT: ret void
; ;
%dest = alloca [16 x i8] %dest = alloca [16 x i8]