Verified Commit 5a6c26ff authored by Tim Gymnich's avatar Tim Gymnich
Browse files

improved debug output

parent 371ad5aa
......@@ -320,12 +320,12 @@ unordered_map<Value const*, int> AffineRelation::createVariableIndexMap(Function
void AffineRelation::printIncoming(BasicBlock const& bb, raw_ostream& out, int indentation) const {
for (auto m: basis) {
out << "\t";
out << llvm::left_justify("", 8);
for (auto [val, idx]: index) {
if (val->hasName()) {
out << val->getName() << "\t\t";
out << llvm::left_justify(val->getName(), 6);
} else {
dbgs(3) << "<>" << "\t\t";
out << llvm::left_justify("<>", 6);
}
}
out << "\n" << m << "\n";
......@@ -334,12 +334,12 @@ void AffineRelation::printIncoming(BasicBlock const& bb, raw_ostream& out, int i
void AffineRelation::printOutgoing(BasicBlock const& bb, raw_ostream& out, int indentation) const {
for (auto m: basis) {
out << "\t";
out << llvm::left_justify("", 8);
for (auto [val, idx]: index) {
if (val->hasName()) {
out << val->getName() << "\t\t";
out << llvm::left_justify(val->getName(), 6);
} else {
dbgs(3) << "<>" << "\t\t";
out << llvm::left_justify("<>", 6);
}
}
out << "\n" << m << "\n";
......@@ -348,12 +348,12 @@ void AffineRelation::printOutgoing(BasicBlock const& bb, raw_ostream& out, int i
void AffineRelation::debug_output(Instruction const& inst, Matrix<int> operands) {
for (auto m: basis) {
dbgs(3) << "\t";
dbgs(3) << llvm::left_justify("", 8);
for (auto [val, idx]: index) {
if (val->hasName()) {
dbgs(3) << val->getName() << "\t\t";
dbgs(3) << llvm::left_justify(val->getName(), 6);
} else {
dbgs(3) << "<>" << "\t\t";
dbgs(3) << llvm::left_justify("<>", 6);
}
}
dbgs(3) << "\n" << m << "\n";
......
......@@ -310,7 +310,7 @@ void executeFixpointAlgorithm(Module const& M) {
dbgs(3) << " Merging with stored state\n";
bool changed = node.state.merge(merge_op, state_new);
dbgs(2) << " Outgoing state is:\n"; state_new.printOutgoing(*node.basic_block, dbgs(2), 4);
dbgs(2) << " Outgoing state " << (changed ? "changd" : "didn't change") << ":\n"; state_new.printOutgoing(*node.basic_block, dbgs(2), 4);
// No changes, so no need to do anything else
if (not changed) continue;
......
#pragma once
#include "llvm/Support/raw_ostream.h"
#include <llvm/Support/raw_ostream.h>
#include <llvm/Support/Format.h>
namespace pcpo {
......
......@@ -372,11 +372,15 @@ inline Matrix<T> operator-(Matrix<T> lhs, T scalar) { return lhs -= scalar; };
template <typename T>
llvm::raw_ostream& operator<<(llvm::raw_ostream& os, Matrix<T> matrix) {
for (int row = 0; row < matrix.getHeight(); row++) {
os << "[\t";
os << "[ ";
for (int column = 0; column < matrix.getWidth(); column++) {
os << matrix(row,column) << "\t\t";
if (column == matrix.getWidth() - 1) {
os << llvm::format("%d", matrix(row,column));
} else {
os << llvm::format("%-6d", matrix(row,column));
}
}
os << "]\n";
os << " ]\n";
}
return os;
};
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment