[llvm] b5ae700 - [StackSafety] Simplify SCEVRewriteVisitor
Vitaly Buka via llvm-commits
llvm-commits at lists.llvm.org
Tue May 26 18:10:02 PDT 2020
Author: Vitaly Buka
Date: 2020-05-26T18:09:43-07:00
New Revision: b5ae70046b0211ff75be8459f7282fe07ad918d8
URL: https://github.com/llvm/llvm-project/commit/b5ae70046b0211ff75be8459f7282fe07ad918d8
DIFF: https://github.com/llvm/llvm-project/commit/b5ae70046b0211ff75be8459f7282fe07ad918d8.diff
LOG: [StackSafety] Simplify SCEVRewriteVisitor
Probably NFC.
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 4b2fc300b118..10b9f14bc75a 100644
--- a/llvm/lib/Analysis/StackSafetyAnalysis.cpp
+++ b/llvm/lib/Analysis/StackSafetyAnalysis.cpp
@@ -42,16 +42,6 @@ class AllocaOffsetRewriter : public SCEVRewriteVisitor<AllocaOffsetRewriter> {
AllocaOffsetRewriter(ScalarEvolution &SE, const Value *AllocaPtr)
: SCEVRewriteVisitor(SE), AllocaPtr(AllocaPtr) {}
- const SCEV *visit(const SCEV *Expr) {
- // Only re-write the expression if the alloca is used in an addition
- // expression (it can be used in other types of expressions if it's cast to
- // an int and passed as an argument.)
- if (!isa<SCEVAddRecExpr>(Expr) && !isa<SCEVAddExpr>(Expr) &&
- !isa<SCEVUnknown>(Expr))
- return Expr;
- return SCEVRewriteVisitor<AllocaOffsetRewriter>::visit(Expr);
- }
-
const SCEV *visitUnknown(const SCEVUnknown *Expr) {
// FIXME: look through one or several levels of definitions?
// This can be inttoptr(AllocaPtr) and SCEV would not unwrap
@@ -237,7 +227,8 @@ ConstantRange StackSafetyLocalAnalysis::offsetFrom(Value *Addr, Value *Base) {
AllocaOffsetRewriter Rewriter(SE, Base);
const SCEV *Expr = Rewriter.visit(SE.getSCEV(Addr));
ConstantRange Offset = SE.getUnsignedRange(Expr).zextOrTrunc(PointerSize);
- assert(!Offset.isEmptySet());
+ if (Offset.isEmptySet())
+ return UnknownRange;
return Offset;
}
diff --git a/llvm/test/Analysis/StackSafetyAnalysis/local.ll b/llvm/test/Analysis/StackSafetyAnalysis/local.ll
index 0ba1694e99eb..b7c9eb1d2953 100644
--- a/llvm/test/Analysis/StackSafetyAnalysis/local.ll
+++ b/llvm/test/Analysis/StackSafetyAnalysis/local.ll
@@ -177,6 +177,7 @@ define void @NonConstantOffset(i1 zeroext %z) {
; CHECK-NEXT: args uses:
; CHECK-NEXT: z[]: full-set{{$}}
; CHECK-NEXT: allocas uses:
+; FIXME: SCEV can't look through selects.
; CHECK-NEXT: x[4]: [0,4){{$}}
; CHECK-NOT: ]:
entry:
More information about the llvm-commits
mailing list