forked from OSchip/llvm-project
parent
4320d4aa1c
commit
b5ae70046b
llvm
|
@ -42,16 +42,6 @@ public:
|
||||||
AllocaOffsetRewriter(ScalarEvolution &SE, const Value *AllocaPtr)
|
AllocaOffsetRewriter(ScalarEvolution &SE, const Value *AllocaPtr)
|
||||||
: SCEVRewriteVisitor(SE), AllocaPtr(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) {
|
const SCEV *visitUnknown(const SCEVUnknown *Expr) {
|
||||||
// FIXME: look through one or several levels of definitions?
|
// FIXME: look through one or several levels of definitions?
|
||||||
// This can be inttoptr(AllocaPtr) and SCEV would not unwrap
|
// 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);
|
AllocaOffsetRewriter Rewriter(SE, Base);
|
||||||
const SCEV *Expr = Rewriter.visit(SE.getSCEV(Addr));
|
const SCEV *Expr = Rewriter.visit(SE.getSCEV(Addr));
|
||||||
ConstantRange Offset = SE.getUnsignedRange(Expr).zextOrTrunc(PointerSize);
|
ConstantRange Offset = SE.getUnsignedRange(Expr).zextOrTrunc(PointerSize);
|
||||||
assert(!Offset.isEmptySet());
|
if (Offset.isEmptySet())
|
||||||
|
return UnknownRange;
|
||||||
return Offset;
|
return Offset;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -177,6 +177,7 @@ define void @NonConstantOffset(i1 zeroext %z) {
|
||||||
; CHECK-NEXT: args uses:
|
; CHECK-NEXT: args uses:
|
||||||
; CHECK-NEXT: z[]: full-set{{$}}
|
; CHECK-NEXT: z[]: full-set{{$}}
|
||||||
; CHECK-NEXT: allocas uses:
|
; CHECK-NEXT: allocas uses:
|
||||||
|
; FIXME: SCEV can't look through selects.
|
||||||
; CHECK-NEXT: x[4]: [0,4){{$}}
|
; CHECK-NEXT: x[4]: [0,4){{$}}
|
||||||
; CHECK-NOT: ]:
|
; CHECK-NOT: ]:
|
||||||
entry:
|
entry:
|
||||||
|
|
Loading…
Reference in New Issue