From 541c2845ded174f8937433fc8a110a2e644919a6 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Sun, 16 May 2021 11:04:45 +0200 Subject: [PATCH] Revert "[CaptureTracking] Do not check domination" This reverts commit 6b8b43e7af3074124e3c9e429e1fb08165799be4. This causes clang test to fail (CodeGenObjC/synchronized.m). Revert until I can figure out whether that's an expected change. --- llvm/lib/Analysis/CaptureTracking.cpp | 8 +++++++- llvm/test/Transforms/MemCpyOpt/callslot.ll | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/llvm/lib/Analysis/CaptureTracking.cpp b/llvm/lib/Analysis/CaptureTracking.cpp index 25815fc57463..e14f6f25dc18 100644 --- a/llvm/lib/Analysis/CaptureTracking.cpp +++ b/llvm/lib/Analysis/CaptureTracking.cpp @@ -143,8 +143,14 @@ namespace { 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. - return !isPotentiallyReachable(I, BeforeHere, nullptr, DT); + if (DT->dominates(BeforeHere, I) && + !isPotentiallyReachable(I, BeforeHere, nullptr, DT)) + return true; + + return false; } bool captured(const Use *U) override { diff --git a/llvm/test/Transforms/MemCpyOpt/callslot.ll b/llvm/test/Transforms/MemCpyOpt/callslot.ll index b9eab2ef8778..037a95ec5176 100644 --- a/llvm/test/Transforms/MemCpyOpt/callslot.ll +++ b/llvm/test/Transforms/MemCpyOpt/callslot.ll @@ -252,8 +252,8 @@ define void @capture_nopath_call(i1 %cond) { ; CHECK-NEXT: call void @accept_ptr(i8* [[DEST_I8]]) ; CHECK-NEXT: ret void ; CHECK: nocaptures: -; CHECK-NEXT: [[DEST1:%.*]] = bitcast [16 x i8]* [[DEST]] to i8* -; CHECK-NEXT: call void @accept_ptr(i8* [[DEST1]]) #[[ATTR3]] +; CHECK-NEXT: call void @accept_ptr(i8* [[SRC_I8]]) #[[ATTR3]] +; CHECK-NEXT: call void @llvm.memcpy.p0i8.p0i8.i64(i8* [[DEST_I8]], i8* [[SRC_I8]], i64 16, i1 false) ; CHECK-NEXT: ret void ; %dest = alloca [16 x i8]