diff --git a/llvm/include/llvm/Analysis/ConstraintSystem.h b/llvm/include/llvm/Analysis/ConstraintSystem.h --- a/llvm/include/llvm/Analysis/ConstraintSystem.h +++ b/llvm/include/llvm/Analysis/ConstraintSystem.h @@ -11,18 +11,23 @@ #include "llvm/ADT/APInt.h" #include "llvm/ADT/ArrayRef.h" +#include "llvm/ADT/DenseMap.h" #include "llvm/ADT/SmallVector.h" #include namespace llvm { - +class Value; class ConstraintSystem { /// Current linear constraints in the system. /// An entry of the form c0, c1, ... cn represents the following constraint: /// c0 >= v0 * c1 + .... + v{n-1} * cn SmallVector, 4> Constraints; + /// a Map between variabled collected in ConstraintElimination and their + /// corresponding index in the constraint system solver. + DenseMap Value2Index; + /// Current greatest common divisor for all coefficients in the system. uint32_t GCD = 1; @@ -52,6 +57,11 @@ return true; } + DenseMap &getValue2Index() { return Value2Index; } + const DenseMap &getValue2Index() const { + return Value2Index; + } + bool addVariableRowFill(ArrayRef R) { // If all variable coefficients are 0, the constraint does not provide any // usable information. diff --git a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp --- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp +++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp @@ -123,8 +123,6 @@ /// based on signed-ness, certain conditions can be transferred between the two /// systems. class ConstraintInfo { - DenseMap UnsignedValue2Index; - DenseMap SignedValue2Index; ConstraintSystem UnsignedCS; ConstraintSystem SignedCS; @@ -135,10 +133,10 @@ ConstraintInfo(const DataLayout &DL) : DL(DL) {} DenseMap &getValue2Index(bool Signed) { - return Signed ? SignedValue2Index : UnsignedValue2Index; + return Signed ? SignedCS.getValue2Index() : UnsignedCS.getValue2Index(); } const DenseMap &getValue2Index(bool Signed) const { - return Signed ? SignedValue2Index : UnsignedValue2Index; + return Signed ? SignedCS.getValue2Index() : UnsignedCS.getValue2Index(); } ConstraintSystem &getCS(bool Signed) {