[llvm] b101c62 - [StackSafety] Ignore some use of values

Vitaly Buka via llvm-commits llvm-commits at lists.llvm.org
Wed May 27 02:50:09 PDT 2020


Author: Vitaly Buka
Date: 2020-05-27T02:48:41-07:00
New Revision: b101c6251a9bce8dc11f47bce70ee169e9fe5bfe

URL: https://github.com/llvm/llvm-project/commit/b101c6251a9bce8dc11f47bce70ee169e9fe5bfe
DIFF: https://github.com/llvm/llvm-project/commit/b101c6251a9bce8dc11f47bce70ee169e9fe5bfe.diff

LOG: [StackSafety] Ignore some use of values

We should ignore value used in MemTransferInst
as other then src/dst argument.

Added: 
    

Modified: 
    llvm/lib/Analysis/StackSafetyAnalysis.cpp
    llvm/test/Analysis/StackSafetyAnalysis/local.ll
    llvm/test/Analysis/StackSafetyAnalysis/memintrin.ll

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/StackSafetyAnalysis.cpp b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
index 1581ca80726b..9c937b0b1dda 100644
--- a/llvm/lib/Analysis/StackSafetyAnalysis.cpp
+++ b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
@@ -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()))

diff  --git a/llvm/test/Analysis/StackSafetyAnalysis/local.ll b/llvm/test/Analysis/StackSafetyAnalysis/local.ll
index f749dc07bb76..eeb7ccbe42d3 100644
--- a/llvm/test/Analysis/StackSafetyAnalysis/local.ll
+++ b/llvm/test/Analysis/StackSafetyAnalysis/local.ll
@@ -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: ]:

diff  --git a/llvm/test/Analysis/StackSafetyAnalysis/memintrin.ll b/llvm/test/Analysis/StackSafetyAnalysis/memintrin.ll
index 87c92aca3538..aec124600b54 100644
--- a/llvm/test/Analysis/StackSafetyAnalysis/memintrin.ll
+++ b/llvm/test/Analysis/StackSafetyAnalysis/memintrin.ll
@@ -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:


        


More information about the llvm-commits mailing list