[llvm] 34ab569 - Support zero size types in StackSafetyAnalysis.
Evgenii Stepanov via llvm-commits
llvm-commits at lists.llvm.org
Mon Jan 27 15:23:21 PST 2020
Author: Evgenii Stepanov
Date: 2020-01-27T15:22:59-08:00
New Revision: 34ab56904e303c6bbe77f4232341b73dd0f2443d
URL: https://github.com/llvm/llvm-project/commit/34ab56904e303c6bbe77f4232341b73dd0f2443d
DIFF: https://github.com/llvm/llvm-project/commit/34ab56904e303c6bbe77f4232341b73dd0f2443d.diff
LOG: Support zero size types in StackSafetyAnalysis.
Reviewers: vitalybuka
Subscribers: hiraditya, llvm-commits
Tags: #llvm
Differential Revision: https://reviews.llvm.org/D73395
Added:
Modified:
llvm/lib/Analysis/StackSafetyAnalysis.cpp
llvm/test/Analysis/StackSafetyAnalysis/local.ll
Removed:
################################################################################
diff --git a/llvm/lib/Analysis/StackSafetyAnalysis.cpp b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
index d85da765b7fe..33a326e4a86f 100644
--- a/llvm/lib/Analysis/StackSafetyAnalysis.cpp
+++ b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
@@ -252,6 +252,10 @@ StackSafetyLocalAnalysis::offsetFromAlloca(Value *Addr,
ConstantRange
StackSafetyLocalAnalysis::getAccessRange(Value *Addr, const Value *AllocaPtr,
ConstantRange SizeRange) {
+ // Zero-size loads and stores do not access memory.
+ if (SizeRange.isEmptySet())
+ return ConstantRange::getEmpty(PointerSize);
+
if (!SE.isSCEVable(Addr->getType()))
return UnknownRange;
diff --git a/llvm/test/Analysis/StackSafetyAnalysis/local.ll b/llvm/test/Analysis/StackSafetyAnalysis/local.ll
index b751297644c8..0ba1694e99eb 100644
--- a/llvm/test/Analysis/StackSafetyAnalysis/local.ll
+++ b/llvm/test/Analysis/StackSafetyAnalysis/local.ll
@@ -368,3 +368,20 @@ entry:
store <vscale x 4 x i32> %v, <vscale x 4 x i32>* %p, align 4
ret void
}
+
+%zerosize_type = type {}
+
+define void @ZeroSize(%zerosize_type *%p) {
+; CHECK-LABEL: @ZeroSize dso_preemptable{{$}}
+; CHECK-NEXT: args uses:
+; CHECK-NEXT: p[]: empty-set
+; CHECK-NEXT: allocas uses:
+; CHECK-NEXT: x[0]: empty-set
+; CHECK-NOT: ]:
+entry:
+ %x = alloca %zerosize_type, align 4
+ store %zerosize_type undef, %zerosize_type* %x, align 4
+ store %zerosize_type undef, %zerosize_type* undef, align 4
+ %val = load %zerosize_type, %zerosize_type* %p, align 4
+ ret void
+}
More information about the llvm-commits
mailing list