This reverts commit
2a2a6bfcfe8e62886542cb673ac8df349cf26499.
This causes build failures:
/home/npopov/repos/llvm-project/llvm/lib/Analysis/ConstraintSystem.cpp: In member function ‘llvm::SmallVector<std::__cxx11::basic_string<char> > llvm::ConstraintSystem::getVarNamesList() const’:
/home/npopov/repos/llvm-project/llvm/lib/Analysis/ConstraintSystem.cpp:118:10: error: invalid use of incomplete type ‘class llvm::Value’
118 | if (V->getName().empty())
| ^~
In file included from /home/npopov/repos/llvm-project/llvm/lib/Analysis/ConstraintSystem.cpp:9:
/home/npopov/repos/llvm-project/llvm/include/llvm/Analysis/ConstraintSystem.h:21:7: note: forward declaration of ‘class llvm::Value’
21 | class Value;
| ^~~~~
/home/npopov/repos/llvm-project/llvm/lib/Analysis/ConstraintSystem.cpp:119:22: error: invalid use of incomplete type ‘class llvm::Value’
119 | OperandName = V->getNameOrAsOperand();
| ^~
/home/npopov/repos/llvm-project/llvm/include/llvm/Analysis/ConstraintSystem.h:21:7: note: forward declaration of ‘class llvm::Value’
21 | class Value;
| ^~~~~
/home/npopov/repos/llvm-project/llvm/lib/Analysis/ConstraintSystem.cpp:121:41: error: invalid use of incomplete type ‘class llvm::Value’
121 | OperandName = std::string("%") + V->getName().str();
| ^~
/home/npopov/repos/llvm-project/llvm/include/llvm/Analysis/ConstraintSystem.h:21:7: note: forward declaration of ‘class llvm::Value’
21 | class Value;
| ^~~~~
// Eliminate constraints from the system using Fourier–Motzkin elimination.
bool eliminateUsingFM();
+ /// Print the constraints in the system, using x0...xn as variable names.
+ void dump() const;
+
/// Returns true if there may be a solution for the constraints in the system.
bool mayHaveSolutionImpl();
- /// Get list of variable names from the Value2Index map.
- SmallVector<std::string> getVarNamesList() const;
-
public:
- ConstraintSystem() {}
- ConstraintSystem(const DenseMap<Value *, unsigned> &Value2Index)
- : Value2Index(Value2Index) {}
-
bool addVariableRow(ArrayRef<int64_t> R) {
assert(Constraints.empty() || R.size() == Constraints.back().size());
// If all variable coefficients are 0, the constraint does not provide any
/// Returns the number of rows in the constraint system.
unsigned size() const { return Constraints.size(); }
- /// Print the constraints in the system.
- void dump() const;
+ /// Print the constraints in the system, using \p Names as variable names.
+ void dump(ArrayRef<std::string> Names) const;
};
} // namespace llvm
return all_of(Constraints, [](auto &R) { return R[0] >= 0; });
}
-SmallVector<std::string> ConstraintSystem::getVarNamesList() const {
- SmallVector<std::string> Names(Value2Index.size(), "");
- for (auto &[V, Index] : Value2Index) {
- std::string OperandName;
- if (V->getName().empty())
- OperandName = V->getNameOrAsOperand();
- else
- OperandName = std::string("%") + V->getName().str();
- Names[Index - 1] = OperandName;
- }
- return Names;
-}
-
-void ConstraintSystem::dump() const {
+void ConstraintSystem::dump(ArrayRef<std::string> Names) const {
if (Constraints.empty())
return;
- SmallVector<std::string> Names = getVarNamesList();
+
for (const auto &Row : Constraints) {
SmallVector<std::string, 16> Parts;
for (unsigned I = 1, S = Row.size(); I < S; ++I) {
}
}
+void ConstraintSystem::dump() const {
+ SmallVector<std::string, 16> Names;
+ for (unsigned i = 1; i < Constraints.back().size(); ++i)
+ Names.push_back("x" + std::to_string(i));
+ LLVM_DEBUG(dbgs() << "---\n");
+ dump(Names);
+}
+
bool ConstraintSystem::mayHaveSolution() {
LLVM_DEBUG(dump());
bool HasSolution = mayHaveSolutionImpl();
} // namespace
#ifndef NDEBUG
+static void dumpWithNames(const ConstraintSystem &CS,
+ DenseMap<Value *, unsigned> &Value2Index) {
+ SmallVector<std::string> Names(Value2Index.size(), "");
+ for (auto &KV : Value2Index) {
+ Names[KV.second - 1] = std::string("%") + KV.first->getName().str();
+ }
+ CS.dump(Names);
+}
-static void dumpConstraint(ArrayRef<int64_t> C,
- const DenseMap<Value *, unsigned> &Value2Index) {
- ConstraintSystem CS(Value2Index);
+static void dumpWithNames(ArrayRef<int64_t> C,
+ DenseMap<Value *, unsigned> &Value2Index) {
+ ConstraintSystem CS;
CS.addVariableRowFill(C);
- CS.dump();
+ dumpWithNames(CS, Value2Index);
}
#endif
LLVM_DEBUG({
dbgs() << "Condition " << *Cmp << " implied by dominating constraints\n";
- CSToUse.dump();
+ dumpWithNames(CSToUse, Info.getValue2Index(R.IsSigned));
});
generateReproducer(Cmp, ReproducerModule, ReproducerCondStack, Info, DT);
Constant *TrueC =
LLVM_DEBUG({
dbgs() << "Condition !" << *Cmp << " implied by dominating constraints\n";
- CSToUse.dump();
+ dumpWithNames(CSToUse, Info.getValue2Index(R.IsSigned));
});
generateReproducer(Cmp, ReproducerModule, ReproducerCondStack, Info, DT);
Constant *FalseC =
LLVM_DEBUG({
dbgs() << " constraint: ";
- dumpConstraint(R.Coefficients, getValue2Index(R.IsSigned));
+ dumpWithNames(R.Coefficients, getValue2Index(R.IsSigned));
dbgs() << "\n";
});
break;
LLVM_DEBUG({
dbgs() << "Removing ";
- dumpConstraint(Info.getCS(E.IsSigned).getLastConstraint(),
- Info.getValue2Index(E.IsSigned));
+ dumpWithNames(Info.getCS(E.IsSigned).getLastConstraint(),
+ Info.getValue2Index(E.IsSigned));
dbgs() << "\n";
});