[StackSafety] Ignore some use of values

We should ignore value used in MemTransferInst
as other then src/dst argument.
This commit is contained in:
Vitaly Buka 2020-05-27 01:42:28 -07:00
parent 84c6433586
commit b101c6251a
3 changed files with 23 additions and 6 deletions

View File

@ -256,10 +256,10 @@ ConstantRange StackSafetyLocalAnalysis::getMemIntrinsicAccessRange(
const MemIntrinsic *MI, const Use &U, Value *Base) {
if (auto MTI = dyn_cast<MemTransferInst>(MI)) {
if (MTI->getRawSource() != U && MTI->getRawDest() != U)
return getRange(0, 1);
return ConstantRange::getEmpty(PointerSize);
} else {
if (MI->getRawDest() != U)
return getRange(0, 1);
return ConstantRange::getEmpty(PointerSize);
}
auto *CalculationTy = IntegerType::getIntNTy(SE.getContext(), PointerSize);
if (!SE.isSCEVable(MI->getLength()->getType()))

View File

@ -356,11 +356,10 @@ for.cond.cleanup:
ret i8 %add
}
; FIXME: we don't understand that %sz in the memset call is limited to 128 by the preceding check.
define dso_local void @SizeCheck(i32 %sz) {
; CHECK-LABEL: @SizeCheck{{$}}
; CHECK-NEXT: args uses:
; CHECK-NEXT: sz[]: [0,1){{$}}
; CHECK-NEXT: sz[]: empty-set{{$}}
; CHECK-NEXT: allocas uses:
; CHECK-NEXT: x1[128]: [0,4294967295){{$}}
; CHECK-NOT: ]:

View File

@ -53,7 +53,7 @@ entry:
define void @MemsetNonConst(i32 %size) {
; CHECK-LABEL: MemsetNonConst dso_preemptable{{$}}
; CHECK-NEXT: args uses:
; CHECK-NEXT: size[]: [0,1){{$}}
; CHECK-NEXT: size[]: empty-set{{$}}
; CHECK-NEXT: allocas uses:
; CHECK-NEXT: x[4]: [0,4294967295){{$}}
; CHECK-NOT: ]:
@ -69,7 +69,7 @@ entry:
define void @MemsetNonConstInBounds(i1 zeroext %z) {
; CHECK-LABEL: MemsetNonConstInBounds dso_preemptable{{$}}
; CHECK-NEXT: args uses:
; CHECK-NEXT: z[]: [0,1){{$}}
; CHECK-NEXT: z[]: empty-set{{$}}
; CHECK-NEXT: allocas uses:
; CHECK-NEXT: x[4]: [0,4294967295){{$}}
; CHECK-NOT: ]:
@ -81,6 +81,24 @@ entry:
ret void
}
define void @MemsetNonConstSize() {
; CHECK-LABEL: MemsetNonConstSize dso_preemptable{{$}}
; CHECK-NEXT: args uses:
; CHECK-NEXT: allocas uses:
; CHECK-NEXT: x[4]: [0,4294967295){{$}}
; CHECK-NEXT: y[4]: empty-set{{$}}
; CHECK-NOT: ]:
entry:
%x = alloca i32, align 4
%y = alloca i32, align 4
%x1 = bitcast i32* %x to i8*
%xint = ptrtoint i32* %x to i32
%yint = ptrtoint i32* %y to i32
%d = sub i32 %xint, %yint
call void @llvm.memset.p0i8.i32(i8* %x1, i8 42, i32 %d, i1 false)
ret void
}
define void @MemcpyInBounds() {
; CHECK-LABEL: MemcpyInBounds dso_preemptable{{$}}
; CHECK-NEXT: args uses: