[PATCH] D153511: [BasicAA] Don't short-circuit non-capturing arguments
Nikita Popov via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 23 01:17:54 PDT 2023
nikic updated this revision to Diff 533891.
nikic added a comment.
Update comment, remove FIXME.
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D153511/new/
https://reviews.llvm.org/D153511
Files:
llvm/lib/Analysis/BasicAliasAnalysis.cpp
llvm/test/Transforms/PhaseOrdering/dse-ephemeral-value-captures.ll
Index: llvm/test/Transforms/PhaseOrdering/dse-ephemeral-value-captures.ll
===================================================================
--- llvm/test/Transforms/PhaseOrdering/dse-ephemeral-value-captures.ll
+++ llvm/test/Transforms/PhaseOrdering/dse-ephemeral-value-captures.ll
@@ -22,11 +22,16 @@
ret i1 0
}
-; FIXME: At the moment, the function is incorrectly simplified to unreachable.
define i32 @test() {
; CHECK-LABEL: define i32 @test() {
; CHECK-NEXT: entry:
-; CHECK-NEXT: unreachable
+; CHECK-NEXT: br label [[THEN_I:%.*]]
+; CHECK: then.i:
+; CHECK-NEXT: [[RES_I:%.*]] = call i1 @cond()
+; CHECK-NEXT: br label [[CHECK_COND_EXIT:%.*]]
+; CHECK: check_cond.exit:
+; CHECK-NEXT: call void @llvm.assume(i1 [[RES_I]])
+; CHECK-NEXT: ret i32 0
;
entry:
%a = alloca i32, align 4
Index: llvm/lib/Analysis/BasicAliasAnalysis.cpp
===================================================================
--- llvm/lib/Analysis/BasicAliasAnalysis.cpp
+++ llvm/lib/Analysis/BasicAliasAnalysis.cpp
@@ -864,9 +864,11 @@
if (!AI->isStaticAlloca() && isIntrinsicCall(Call, Intrinsic::stackrestore))
return ModRefInfo::Mod;
- // If the pointer is to a locally allocated object that does not escape,
- // then the call can not mod/ref the pointer unless the call takes the pointer
- // as an argument, and itself doesn't capture it.
+ // A call can access a locally allocated object either because it is passed as
+ // an argument to the call, or because it has escaped prior to the call.
+ //
+ // Make sure the object has not escaped here, and then check that none of the
+ // call arguments alias the object below.
if (!isa<Constant>(Object) && Call != Object &&
AAQI.CI->isNotCapturedBeforeOrAt(Object, Call)) {
@@ -877,12 +879,7 @@
unsigned OperandNo = 0;
for (auto CI = Call->data_operands_begin(), CE = Call->data_operands_end();
CI != CE; ++CI, ++OperandNo) {
- // Only look at the no-capture or byval pointer arguments. If this
- // pointer were passed to arguments that were neither of these, then it
- // couldn't be no-capture.
- if (!(*CI)->getType()->isPointerTy() ||
- (!Call->doesNotCapture(OperandNo) && OperandNo < Call->arg_size() &&
- !Call->isByValArgument(OperandNo)))
+ if (!(*CI)->getType()->isPointerTy())
continue;
// Call doesn't access memory through this operand, so we don't care
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D153511.533891.patch
Type: text/x-patch
Size: 2465 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230623/5ef80b8b/attachment.bin>
More information about the llvm-commits
mailing list