Files
clang-p2996/llvm/test/Transforms/MemCpyOpt/aa-recursion-assertion-failure.ll
Nikita Popov b1c2f1282a [BasicAA] Move assumption tracking into AAQI
D91936 placed the tracking for the assumptions into BasicAA.
However, when recursing over phis, we may use fresh AAQI instances.
In this case AssumptionBasedResults from an inner AAQI can reesult
in a removal of an element from the outer AAQI.

To avoid this, move the tracking into AAQI. This generally makes
more sense, as the NoAlias assumptions themselves are also stored
in AAQI.

The test case only produces an assertion failure with D90094
reapplied. I think the issue exists independently of that change
as well, but I wasn't able to come up with a reproducer.
2021-01-17 10:34:35 +01:00

87 lines
4.3 KiB
LLVM

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -S -scoped-noalias-aa -memcpyopt < %s | FileCheck %s
; ModuleID = '<stdin>'
source_filename = "test.cpp"
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64-unknown-linux-android21"
define dso_local void @_Z1ml(i64 %e) {
; CHECK-LABEL: @_Z1ml(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[L:%.*]] = alloca i8, align 1
; CHECK-NEXT: br label [[WHILE_COND:%.*]]
; CHECK: for.cond.while.cond.loopexit_crit_edge.us-lcssa:
; CHECK-NEXT: br label [[WHILE_COND_LOOPEXIT:%.*]]
; CHECK: while.cond.loopexit:
; CHECK-NEXT: [[TMP0:%.*]] = phi i8* [ [[ADD_PTR_I:%.*]], [[FOR_COND_WHILE_COND_LOOPEXIT_CRIT_EDGE_US_LCSSA:%.*]] ], [ [[TMP1:%.*]], [[WHILE_COND]] ]
; CHECK-NEXT: [[I_1_LCSSA:%.*]] = phi i8* [ [[I_2:%.*]], [[FOR_COND_WHILE_COND_LOOPEXIT_CRIT_EDGE_US_LCSSA]] ], [ [[I_0:%.*]], [[WHILE_COND]] ]
; CHECK-NEXT: br label [[WHILE_COND]]
; CHECK: while.cond:
; CHECK-NEXT: [[TMP1]] = phi i8* [ [[L]], [[ENTRY:%.*]] ], [ [[TMP0]], [[WHILE_COND_LOOPEXIT]] ]
; CHECK-NEXT: [[I_0]] = phi i8* [ [[L]], [[ENTRY]] ], [ [[I_1_LCSSA]], [[WHILE_COND_LOOPEXIT]] ]
; CHECK-NEXT: br i1 undef, label [[FOR_BODY_LR_PH:%.*]], label [[WHILE_COND_LOOPEXIT]]
; CHECK: for.body.lr.ph:
; CHECK-NEXT: br label [[FOR_BODY:%.*]]
; CHECK: for.body:
; CHECK-NEXT: [[TMP2:%.*]] = phi i8* [ [[TMP1]], [[FOR_BODY_LR_PH]] ], [ [[ADD_PTR_I]], [[IF_END5:%.*]] ]
; CHECK-NEXT: [[I_15:%.*]] = phi i8* [ [[I_0]], [[FOR_BODY_LR_PH]] ], [ [[I_2]], [[IF_END5]] ]
; CHECK-NEXT: [[ADD_PTR_I]] = getelementptr inbounds i8, i8* [[TMP2]], i64 [[E:%.*]]
; CHECK-NEXT: [[TMP3:%.*]] = load i8, i8* [[TMP2]], align 1, !noalias !0
; CHECK-NEXT: [[TMP4:%.*]] = load i8, i8* [[I_15]], align 1, !alias.scope !0
; CHECK-NEXT: store i8 [[TMP4]], i8* [[TMP2]], align 1
; CHECK-NEXT: br label [[_Z1DPCS_L_EXIT:%.*]]
; CHECK: _Z1dPcS_l.exit:
; CHECK-NEXT: br i1 undef, label [[IF_THEN3:%.*]], label [[IF_END5]]
; CHECK: if.then3:
; CHECK-NEXT: [[ADD_PTR4:%.*]] = getelementptr inbounds i8, i8* [[I_15]], i64 [[E]]
; CHECK-NEXT: br label [[IF_END5]]
; CHECK: if.end5:
; CHECK-NEXT: [[I_2]] = phi i8* [ [[ADD_PTR4]], [[IF_THEN3]] ], [ [[I_15]], [[_Z1DPCS_L_EXIT]] ]
; CHECK-NEXT: br i1 false, label [[FOR_BODY]], label [[FOR_COND_WHILE_COND_LOOPEXIT_CRIT_EDGE_US_LCSSA]]
;
entry:
%l = alloca i8, align 1
br label %while.cond
for.cond.while.cond.loopexit_crit_edge.us-lcssa: ; preds = %if.end5
br label %while.cond.loopexit
while.cond.loopexit: ; preds = %while.cond, %for.cond.while.cond.loopexit_crit_edge.us-lcssa
%0 = phi i8* [ %add.ptr.i, %for.cond.while.cond.loopexit_crit_edge.us-lcssa ], [ %1, %while.cond ]
%i.1.lcssa = phi i8* [ %i.2, %for.cond.while.cond.loopexit_crit_edge.us-lcssa ], [ %i.0, %while.cond ]
br label %while.cond
while.cond: ; preds = %while.cond.loopexit, %entry
%1 = phi i8* [ %l, %entry ], [ %0, %while.cond.loopexit ]
%i.0 = phi i8* [ %l, %entry ], [ %i.1.lcssa, %while.cond.loopexit ]
br i1 undef, label %for.body.lr.ph, label %while.cond.loopexit
for.body.lr.ph: ; preds = %while.cond
br label %for.body
for.body: ; preds = %if.end5, %for.body.lr.ph
%2 = phi i8* [ %1, %for.body.lr.ph ], [ %add.ptr.i, %if.end5 ]
%i.15 = phi i8* [ %i.0, %for.body.lr.ph ], [ %i.2, %if.end5 ]
%add.ptr.i = getelementptr inbounds i8, i8* %2, i64 %e
%3 = load i8, i8* %2, align 1, !noalias !0
%4 = load i8, i8* %i.15, align 1, !alias.scope !0
store i8 %4, i8* %2, align 1
br label %_Z1dPcS_l.exit
_Z1dPcS_l.exit: ; preds = %for.body
br i1 undef, label %if.then3, label %if.end5
if.then3: ; preds = %_Z1dPcS_l.exit
%add.ptr4 = getelementptr inbounds i8, i8* %i.15, i64 %e
br label %if.end5
if.end5: ; preds = %if.then3, %_Z1dPcS_l.exit
%i.2 = phi i8* [ %add.ptr4, %if.then3 ], [ %i.15, %_Z1dPcS_l.exit ]
br i1 false, label %for.body, label %for.cond.while.cond.loopexit_crit_edge.us-lcssa
}
!0 = !{!1}
!1 = distinct !{!1, !2, !"_Z1dPcS_l: %h"}
!2 = distinct !{!2, !"_Z1dPcS_l"}