aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZain Jaffal <z_jaffal@apple.com>2023-02-08 11:31:42 +0000
committerZain Jaffal <z_jaffal@apple.com>2023-02-08 14:52:43 +0000
commita9d6a86b214e03fbaa68c10c482be2b9aea894ef (patch)
tree484179d261b7cb2e75f5a5ae15acb83b7c0c25b5
parent22a5593b0389c810c62ecae2b696d626c7ac0355 (diff)
downloadllvm-a9d6a86b214e03fbaa68c10c482be2b9aea894ef.zip
llvm-a9d6a86b214e03fbaa68c10c482be2b9aea894ef.tar.gz
llvm-a9d6a86b214e03fbaa68c10c482be2b9aea894ef.tar.bz2
Recommit "[ConstraintElimination] Move Value2Index map to ConstraintSystem (NFC)"
This reverts commit 665ee0cd57f92a112cf8e929d00768e282fb205a. Fix comments and formatting style.
-rw-r--r--llvm/include/llvm/Analysis/ConstraintSystem.h12
-rw-r--r--llvm/lib/Transforms/Scalar/ConstraintElimination.cpp6
2 files changed, 14 insertions, 4 deletions
diff --git a/llvm/include/llvm/Analysis/ConstraintSystem.h b/llvm/include/llvm/Analysis/ConstraintSystem.h
index 719fe33..3e1bfbc 100644
--- a/llvm/include/llvm/Analysis/ConstraintSystem.h
+++ b/llvm/include/llvm/Analysis/ConstraintSystem.h
@@ -11,18 +11,25 @@
#include "llvm/ADT/APInt.h"
#include "llvm/ADT/ArrayRef.h"
+#include "llvm/ADT/DenseMap.h"
#include "llvm/ADT/SmallVector.h"
#include <string>
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<SmallVector<int64_t, 8>, 4> Constraints;
+ /// A map of variables (IR values) to their corresponding index in the
+ /// constraint system.
+ DenseMap<Value *, unsigned> Value2Index;
+
/// Current greatest common divisor for all coefficients in the system.
uint32_t GCD = 1;
@@ -52,6 +59,11 @@ public:
return true;
}
+ DenseMap<Value *, unsigned> &getValue2Index() { return Value2Index; }
+ const DenseMap<Value *, unsigned> &getValue2Index() const {
+ return Value2Index;
+ }
+
bool addVariableRowFill(ArrayRef<int64_t> 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
index 12fcb6a..f1bb73a 100644
--- a/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
+++ b/llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
@@ -123,8 +123,6 @@ struct ConstraintTy {
/// based on signed-ness, certain conditions can be transferred between the two
/// systems.
class ConstraintInfo {
- DenseMap<Value *, unsigned> UnsignedValue2Index;
- DenseMap<Value *, unsigned> SignedValue2Index;
ConstraintSystem UnsignedCS;
ConstraintSystem SignedCS;
@@ -135,10 +133,10 @@ public:
ConstraintInfo(const DataLayout &DL) : DL(DL) {}
DenseMap<Value *, unsigned> &getValue2Index(bool Signed) {
- return Signed ? SignedValue2Index : UnsignedValue2Index;
+ return Signed ? SignedCS.getValue2Index() : UnsignedCS.getValue2Index();
}
const DenseMap<Value *, unsigned> &getValue2Index(bool Signed) const {
- return Signed ? SignedValue2Index : UnsignedValue2Index;
+ return Signed ? SignedCS.getValue2Index() : UnsignedCS.getValue2Index();
}
ConstraintSystem &getCS(bool Signed) {