1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-19 02:52:53 +02:00

[StackSafety] Simplify SCEVRewriteVisitor

Probably NFC.
This commit is contained in:
Vitaly Buka 2020-05-26 17:04:09 -07:00
parent c6f45da340
commit 23018c295b
2 changed files with 3 additions and 11 deletions

View File

@ -42,16 +42,6 @@ public:
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;
}

View File

@ -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: