Rangeanalysis: Preparatory refactor for bounds sharing.

This commit is contained in:
Anders Schack-Mulligen 2023-11-29 09:24:42 +01:00
Родитель d8f53e5524
Коммит 6b178fb64a
4 изменённых файлов: 25 добавлений и 4 удалений

Просмотреть файл

@ -25,4 +25,8 @@ module CppLangImplConstant implements LangSig<Sem, FloatDelta> {
* Holds if `e2 >= e1 + delta` (if `upper = false`) or `e2 <= e1 + delta` (if `upper = true`).
*/
predicate additionalBoundFlowStep(SemExpr e2, SemExpr e1, float delta, boolean upper) { none() }
predicate includeConstantBounds() { any() }
predicate includeRelativeBounds() { none() }
}

Просмотреть файл

@ -173,11 +173,11 @@ private module ModulusAnalysisInstantiated implements ModulusAnalysisSig<Sem> {
}
module ConstantStage =
RangeStage<SemLocation, Sem, FloatDelta, ConstantBounds, FloatOverflow, CppLangImplConstant,
RangeStage<SemLocation, Sem, FloatDelta, AllBounds, FloatOverflow, CppLangImplConstant,
SignAnalysis, ModulusAnalysisInstantiated>;
module RelativeStage =
RangeStage<SemLocation, Sem, FloatDelta, RelativeBounds, FloatOverflow, CppLangImplRelative,
RangeStage<SemLocation, Sem, FloatDelta, AllBounds, FloatOverflow, CppLangImplRelative,
SignAnalysis, ModulusAnalysisInstantiated>;
private newtype TSemReason =

Просмотреть файл

@ -57,4 +57,8 @@ module CppLangImplRelative implements LangSig<Sem, FloatDelta> {
* Holds if `e2 >= e1 + delta` (if `upper = false`) or `e2 <= e1 + delta` (if `upper = true`).
*/
predicate additionalBoundFlowStep(SemExpr e2, SemExpr e1, float delta, boolean upper) { none() }
predicate includeConstantBounds() { none() }
predicate includeRelativeBounds() { any() }
}

Просмотреть файл

@ -289,6 +289,10 @@ signature module LangSig<Semantic Sem, DeltaSig D> {
predicate ignoreExprBound(Sem::Expr e);
default predicate javaCompatibility() { none() }
default predicate includeConstantBounds() { any() }
default predicate includeRelativeBounds() { any() }
}
signature module BoundSig<LocationSig Location, Semantic Sem, DeltaSig D> {
@ -983,6 +987,13 @@ module RangeStage<
)
}
private predicate includeBound(SemBound b) {
// always include phi bounds
b.(SemSsaBound).getVariable() instanceof Sem::SsaPhiNode
or
if b instanceof SemZeroBound then includeConstantBounds() else includeRelativeBounds()
}
/**
* Holds if `e` has an upper (for `upper = true`) or lower
* (for `upper = false`) bound of `b`.
@ -1122,13 +1133,15 @@ module RangeStage<
(upper = true or upper = false) and
fromBackEdge = false and
origdelta = delta and
reason = TSemNoReason()
reason = TSemNoReason() and
includeBound(b)
or
baseBound(e, delta, upper) and
b instanceof SemZeroBound and
fromBackEdge = false and
origdelta = delta and
reason = TSemNoReason()
reason = TSemNoReason() and
includeBound(b)
or
exists(Sem::SsaVariable v, SsaReadPositionBlock bb |
boundedSsa(v, b, delta, bb, upper, fromBackEdge, origdelta, reason) and