aboutsummaryrefslogtreecommitdiff
path: root/lib/Transforms
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2005-05-08 20:09:57 +0000
committerChris Lattner <sabre@nondot.org>2005-05-08 20:09:57 +0000
commitc9fd097a01383323f166c14c17d3984620cad766 (patch)
tree38ddb604cc4c23500e2c6647dcf7aaff6d681a86 /lib/Transforms
parent989f6229bcef6e7a0ec8f5c8b0013051c0b56b59 (diff)
Add debugging information
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@21781 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms')
-rw-r--r--lib/Transforms/Scalar/Reassociate.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/lib/Transforms/Scalar/Reassociate.cpp b/lib/Transforms/Scalar/Reassociate.cpp
index 840b8f2e81..ffa7c84c6c 100644
--- a/lib/Transforms/Scalar/Reassociate.cpp
+++ b/lib/Transforms/Scalar/Reassociate.cpp
@@ -27,6 +27,7 @@
#include "llvm/Instructions.h"
#include "llvm/Pass.h"
#include "llvm/Type.h"
+#include "llvm/Assembly/Writer.h"
#include "llvm/Support/CFG.h"
#include "llvm/Support/Debug.h"
#include "llvm/ADT/PostOrderIterator.h"
@@ -498,6 +499,17 @@ void Reassociate::OptimizeExpression(unsigned Opcode,
OptimizeExpression(Opcode, Ops);
}
+/// PrintOps - Print out the expression identified in the Ops list.
+///
+static void PrintOps(unsigned Opcode, const std::vector<ValueEntry> &Ops,
+ BasicBlock *BB) {
+ Module *M = BB->getParent()->getParent();
+ std::cerr << Instruction::getOpcodeName(Opcode) << " "
+ << *Ops[0].Op->getType();
+ for (unsigned i = 0, e = Ops.size(); i != e; ++i)
+ WriteAsOperand(std::cerr << " ", Ops[i].Op, false, true, M)
+ << "," << Ops[i].Rank;
+}
/// ReassociateBB - Inspect all of the instructions in this basic block,
/// reassociating them as we go.
@@ -530,6 +542,9 @@ void Reassociate::ReassociateBB(BasicBlock *BB) {
std::vector<ValueEntry> Ops;
LinearizeExprTree(I, Ops);
+ DEBUG(std::cerr << "RAIn:\t"; PrintOps(I->getOpcode(), Ops, BB);
+ std::cerr << "\n");
+
// Now that we have linearized the tree to a list and have gathered all of
// the operands and their ranks, sort the operands by their rank. Use a
// stable_sort so that values with equal ranks will have their relative
@@ -542,6 +557,9 @@ void Reassociate::ReassociateBB(BasicBlock *BB) {
// sorted form, optimize it globally if possible.
OptimizeExpression(I->getOpcode(), Ops);
+ DEBUG(std::cerr << "RAOut:\t"; PrintOps(I->getOpcode(), Ops, BB);
+ std::cerr << "\n");
+
if (Ops.size() == 1) {
// This expression tree simplified to something that isn't a tree,
// eliminate it.