diff options
Diffstat (limited to 'mlir/lib/Analysis/DataFlow')
-rw-r--r-- | mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp | 8 | ||||
-rw-r--r-- | mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp | 130 | ||||
-rw-r--r-- | mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp | 83 |
3 files changed, 109 insertions, 112 deletions
diff --git a/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp b/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp index 51fa773..fb5649e 100644 --- a/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp +++ b/mlir/lib/Analysis/DataFlow/ConstantPropagationAnalysis.cpp @@ -16,6 +16,7 @@ #include "llvm/ADT/STLExtras.h" #include "llvm/Support/Casting.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/DebugLog.h" #include <cassert> #define DEBUG_TYPE "constant-propagation" @@ -46,7 +47,7 @@ void ConstantValue::print(raw_ostream &os) const { LogicalResult SparseConstantPropagation::visitOperation( Operation *op, ArrayRef<const Lattice<ConstantValue> *> operands, ArrayRef<Lattice<ConstantValue> *> results) { - LLVM_DEBUG(llvm::dbgs() << "SCP: Visiting operation: " << *op << "\n"); + LDBG() << "SCP: Visiting operation: " << *op; // Don't try to simulate the results of a region operation as we can't // guarantee that folding will be out-of-place. We don't allow in-place @@ -98,12 +99,11 @@ LogicalResult SparseConstantPropagation::visitOperation( // Merge in the result of the fold, either a constant or a value. OpFoldResult foldResult = std::get<1>(it); if (Attribute attr = llvm::dyn_cast_if_present<Attribute>(foldResult)) { - LLVM_DEBUG(llvm::dbgs() << "Folded to constant: " << attr << "\n"); + LDBG() << "Folded to constant: " << attr; propagateIfChanged(lattice, lattice->join(ConstantValue(attr, op->getDialect()))); } else { - LLVM_DEBUG(llvm::dbgs() - << "Folded to value: " << cast<Value>(foldResult) << "\n"); + LDBG() << "Folded to value: " << cast<Value>(foldResult); AbstractSparseForwardDataFlowAnalysis::join( lattice, *getLatticeElement(cast<Value>(foldResult))); } diff --git a/mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp b/mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp index 1abdfcb..10874fd 100644 --- a/mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp +++ b/mlir/lib/Analysis/DataFlow/DeadCodeAnalysis.cpp @@ -23,12 +23,11 @@ #include "mlir/Support/LLVM.h" #include "llvm/Support/Casting.h" #include "llvm/Support/Debug.h" +#include "llvm/Support/DebugLog.h" #include <cassert> #include <optional> #define DEBUG_TYPE "dead-code-analysis" -#define DBGS() (llvm::dbgs() << '[' << DEBUG_TYPE << "] ") -#define LDBG(X) LLVM_DEBUG(DBGS() << X << "\n") using namespace mlir; using namespace mlir::dataflow; @@ -127,7 +126,8 @@ DeadCodeAnalysis::DeadCodeAnalysis(DataFlowSolver &solver) } LogicalResult DeadCodeAnalysis::initialize(Operation *top) { - LDBG("Initializing DeadCodeAnalysis for top-level op: " << top->getName()); + LDBG() << "Initializing DeadCodeAnalysis for top-level op: " + << top->getName(); // Mark the top-level blocks as executable. for (Region ®ion : top->getRegions()) { if (region.empty()) @@ -135,7 +135,7 @@ LogicalResult DeadCodeAnalysis::initialize(Operation *top) { auto *state = getOrCreate<Executable>(getProgramPointBefore(®ion.front())); propagateIfChanged(state, state->setToLive()); - LDBG("Marked entry block live for region in op: " << top->getName()); + LDBG() << "Marked entry block live for region in op: " << top->getName(); } // Mark as overdefined the predecessors of symbol callables with potentially @@ -146,18 +146,18 @@ LogicalResult DeadCodeAnalysis::initialize(Operation *top) { } void DeadCodeAnalysis::initializeSymbolCallables(Operation *top) { - LDBG("[init] Entering initializeSymbolCallables for top-level op: " - << top->getName()); + LDBG() << "[init] Entering initializeSymbolCallables for top-level op: " + << top->getName(); analysisScope = top; auto walkFn = [&](Operation *symTable, bool allUsesVisible) { - LDBG("[init] Processing symbol table op: " << symTable->getName()); + LDBG() << "[init] Processing symbol table op: " << symTable->getName(); Region &symbolTableRegion = symTable->getRegion(0); Block *symbolTableBlock = &symbolTableRegion.front(); bool foundSymbolCallable = false; for (auto callable : symbolTableBlock->getOps<CallableOpInterface>()) { - LDBG("[init] Found CallableOpInterface: " - << callable.getOperation()->getName()); + LDBG() << "[init] Found CallableOpInterface: " + << callable.getOperation()->getName(); Region *callableRegion = callable.getCallableRegion(); if (!callableRegion) continue; @@ -171,8 +171,8 @@ void DeadCodeAnalysis::initializeSymbolCallables(Operation *top) { auto *state = getOrCreate<PredecessorState>(getProgramPointAfter(callable)); propagateIfChanged(state, state->setHasUnknownPredecessors()); - LDBG("[init] Marked callable as having unknown predecessors: " - << callable.getOperation()->getName()); + LDBG() << "[init] Marked callable as having unknown predecessors: " + << callable.getOperation()->getName(); } foundSymbolCallable = true; } @@ -187,15 +187,15 @@ void DeadCodeAnalysis::initializeSymbolCallables(Operation *top) { if (!uses) { // If we couldn't gather the symbol uses, conservatively assume that // we can't track information for any nested symbols. - LDBG("[init] Could not gather symbol uses, conservatively marking " - "all nested callables as having unknown predecessors"); + LDBG() << "[init] Could not gather symbol uses, conservatively marking " + "all nested callables as having unknown predecessors"; return top->walk([&](CallableOpInterface callable) { auto *state = getOrCreate<PredecessorState>(getProgramPointAfter(callable)); propagateIfChanged(state, state->setHasUnknownPredecessors()); - LDBG("[init] Marked nested callable as " - "having unknown predecessors: " - << callable.getOperation()->getName()); + LDBG() << "[init] Marked nested callable as " + "having unknown predecessors: " + << callable.getOperation()->getName(); }); } @@ -209,15 +209,15 @@ void DeadCodeAnalysis::initializeSymbolCallables(Operation *top) { continue; auto *state = getOrCreate<PredecessorState>(getProgramPointAfter(symbol)); propagateIfChanged(state, state->setHasUnknownPredecessors()); - LDBG("[init] Found non-call use for symbol, " - "marked as having unknown predecessors: " - << symbol->getName()); + LDBG() << "[init] Found non-call use for symbol, " + "marked as having unknown predecessors: " + << symbol->getName(); } }; SymbolTable::walkSymbolTables(top, /*allSymUsesVisible=*/!top->getBlock(), walkFn); - LDBG("[init] Finished initializeSymbolCallables for top-level op: " - << top->getName()); + LDBG() << "[init] Finished initializeSymbolCallables for top-level op: " + << top->getName(); } /// Returns true if the operation is a returning terminator in region @@ -229,14 +229,14 @@ static bool isRegionOrCallableReturn(Operation *op) { } LogicalResult DeadCodeAnalysis::initializeRecursively(Operation *op) { - LDBG("[init] Entering initializeRecursively for op: " << op->getName() - << " at " << op); + LDBG() << "[init] Entering initializeRecursively for op: " << op->getName() + << " at " << op; // Initialize the analysis by visiting every op with control-flow semantics. if (op->getNumRegions() || op->getNumSuccessors() || isRegionOrCallableReturn(op) || isa<CallOpInterface>(op)) { - LDBG("[init] Visiting op with control-flow semantics: " << *op); - // When the liveness of the parent block changes, make sure to re-invoke the - // analysis on the op. + LDBG() << "[init] Visiting op with control-flow semantics: " << *op; + // When the liveness of the parent block changes, make sure to + // re-invoke the analysis on the op. if (op->getBlock()) getOrCreate<Executable>(getProgramPointBefore(op->getBlock())) ->blockContentSubscribe(this); @@ -246,21 +246,21 @@ LogicalResult DeadCodeAnalysis::initializeRecursively(Operation *op) { } // Recurse on nested operations. for (Region ®ion : op->getRegions()) { - LDBG("[init] Recursing into region of op: " << op->getName()); + LDBG() << "[init] Recursing into region of op: " << op->getName(); for (Operation &nestedOp : region.getOps()) { - LDBG("[init] Recursing into nested op: " << nestedOp.getName() << " at " - << &nestedOp); + LDBG() << "[init] Recursing into nested op: " << nestedOp.getName() + << " at " << &nestedOp; if (failed(initializeRecursively(&nestedOp))) return failure(); } } - LDBG("[init] Finished initializeRecursively for op: " << op->getName() - << " at " << op); + LDBG() << "[init] Finished initializeRecursively for op: " << op->getName() + << " at " << op; return success(); } void DeadCodeAnalysis::markEdgeLive(Block *from, Block *to) { - LDBG("Marking edge live from block " << from << " to block " << to); + LDBG() << "Marking edge live from block " << from << " to block " << to; auto *state = getOrCreate<Executable>(getProgramPointBefore(to)); propagateIfChanged(state, state->setToLive()); auto *edgeState = @@ -269,35 +269,35 @@ void DeadCodeAnalysis::markEdgeLive(Block *from, Block *to) { } void DeadCodeAnalysis::markEntryBlocksLive(Operation *op) { - LDBG("Marking entry blocks live for op: " << op->getName()); + LDBG() << "Marking entry blocks live for op: " << op->getName(); for (Region ®ion : op->getRegions()) { if (region.empty()) continue; auto *state = getOrCreate<Executable>(getProgramPointBefore(®ion.front())); propagateIfChanged(state, state->setToLive()); - LDBG("Marked entry block live for region in op: " << op->getName()); + LDBG() << "Marked entry block live for region in op: " << op->getName(); } } LogicalResult DeadCodeAnalysis::visit(ProgramPoint *point) { - LDBG("Visiting program point: " << point << " " << *point); + LDBG() << "Visiting program point: " << point << " " << *point; if (point->isBlockStart()) return success(); Operation *op = point->getPrevOp(); - LDBG("Visiting operation: " << *op); + LDBG() << "Visiting operation: " << *op; // If the parent block is not executable, there is nothing to do. if (op->getBlock() != nullptr && !getOrCreate<Executable>(getProgramPointBefore(op->getBlock())) ->isLive()) { - LDBG("Parent block not live, skipping op: " << *op); + LDBG() << "Parent block not live, skipping op: " << *op; return success(); } // We have a live call op. Add this as a live predecessor of the callee. if (auto call = dyn_cast<CallOpInterface>(op)) { - LDBG("Visiting call operation: " << *op); + LDBG() << "Visiting call operation: " << *op; visitCallOperation(call); } @@ -305,12 +305,12 @@ LogicalResult DeadCodeAnalysis::visit(ProgramPoint *point) { if (op->getNumRegions()) { // Check if we can reason about the region control-flow. if (auto branch = dyn_cast<RegionBranchOpInterface>(op)) { - LDBG("Visiting region branch operation: " << *op); + LDBG() << "Visiting region branch operation: " << *op; visitRegionBranchOperation(branch); // Check if this is a callable operation. } else if (auto callable = dyn_cast<CallableOpInterface>(op)) { - LDBG("Visiting callable operation: " << *op); + LDBG() << "Visiting callable operation: " << *op; const auto *callsites = getOrCreateFor<PredecessorState>( getProgramPointAfter(op), getProgramPointAfter(callable)); @@ -322,19 +322,19 @@ LogicalResult DeadCodeAnalysis::visit(ProgramPoint *point) { // Otherwise, conservatively mark all entry blocks as executable. } else { - LDBG("Marking all entry blocks live for op: " << *op); + LDBG() << "Marking all entry blocks live for op: " << *op; markEntryBlocksLive(op); } } if (isRegionOrCallableReturn(op)) { if (auto branch = dyn_cast<RegionBranchOpInterface>(op->getParentOp())) { - LDBG("Visiting region terminator: " << *op); + LDBG() << "Visiting region terminator: " << *op; // Visit the exiting terminator of a region. visitRegionTerminator(op, branch); } else if (auto callable = dyn_cast<CallableOpInterface>(op->getParentOp())) { - LDBG("Visiting callable terminator: " << *op); + LDBG() << "Visiting callable terminator: " << *op; // Visit the exiting terminator of a callable. visitCallableTerminator(op, callable); } @@ -343,12 +343,12 @@ LogicalResult DeadCodeAnalysis::visit(ProgramPoint *point) { if (op->getNumSuccessors()) { // Check if we can reason about the control-flow. if (auto branch = dyn_cast<BranchOpInterface>(op)) { - LDBG("Visiting branch operation: " << *op); + LDBG() << "Visiting branch operation: " << *op; visitBranchOperation(branch); // Otherwise, conservatively mark all successors as exectuable. } else { - LDBG("Marking all successors live for op: " << *op); + LDBG() << "Marking all successors live for op: " << *op; for (Block *successor : op->getSuccessors()) markEdgeLive(op->getBlock(), successor); } @@ -358,7 +358,7 @@ LogicalResult DeadCodeAnalysis::visit(ProgramPoint *point) { } void DeadCodeAnalysis::visitCallOperation(CallOpInterface call) { - LDBG("visitCallOperation: " << call.getOperation()->getName()); + LDBG() << "visitCallOperation: " << call.getOperation()->getName(); Operation *callableOp = call.resolveCallableInTable(&symbolTable); // A call to a externally-defined callable has unknown predecessors. @@ -381,15 +381,15 @@ void DeadCodeAnalysis::visitCallOperation(CallOpInterface call) { auto *callsites = getOrCreate<PredecessorState>(getProgramPointAfter(callableOp)); propagateIfChanged(callsites, callsites->join(call)); - LDBG("Added callsite as predecessor for callable: " - << callableOp->getName()); + LDBG() << "Added callsite as predecessor for callable: " + << callableOp->getName(); } else { // Mark this call op's predecessors as overdefined. auto *predecessors = getOrCreate<PredecessorState>(getProgramPointAfter(call)); propagateIfChanged(predecessors, predecessors->setHasUnknownPredecessors()); - LDBG("Marked call op's predecessors as unknown for: " - << call.getOperation()->getName()); + LDBG() << "Marked call op's predecessors as unknown for: " + << call.getOperation()->getName(); } } @@ -421,7 +421,7 @@ DeadCodeAnalysis::getOperandValues(Operation *op) { } void DeadCodeAnalysis::visitBranchOperation(BranchOpInterface branch) { - LDBG("visitBranchOperation: " << branch.getOperation()->getName()); + LDBG() << "visitBranchOperation: " << branch.getOperation()->getName(); // Try to deduce a single successor for the branch. std::optional<SmallVector<Attribute>> operands = getOperandValues(branch); if (!operands) @@ -429,18 +429,18 @@ void DeadCodeAnalysis::visitBranchOperation(BranchOpInterface branch) { if (Block *successor = branch.getSuccessorForOperands(*operands)) { markEdgeLive(branch->getBlock(), successor); - LDBG("Branch has single successor: " << successor); + LDBG() << "Branch has single successor: " << successor; } else { // Otherwise, mark all successors as executable and outgoing edges. for (Block *successor : branch->getSuccessors()) markEdgeLive(branch->getBlock(), successor); - LDBG("Branch has multiple/all successors live"); + LDBG() << "Branch has multiple/all successors live"; } } void DeadCodeAnalysis::visitRegionBranchOperation( RegionBranchOpInterface branch) { - LDBG("visitRegionBranchOperation: " << branch.getOperation()->getName()); + LDBG() << "visitRegionBranchOperation: " << branch.getOperation()->getName(); // Try to deduce which regions are executable. std::optional<SmallVector<Attribute>> operands = getOperandValues(branch); if (!operands) @@ -457,19 +457,19 @@ void DeadCodeAnalysis::visitRegionBranchOperation( // Mark the entry block as executable. auto *state = getOrCreate<Executable>(point); propagateIfChanged(state, state->setToLive()); - LDBG("Marked region successor live: " << point); + LDBG() << "Marked region successor live: " << point; // Add the parent op as a predecessor. auto *predecessors = getOrCreate<PredecessorState>(point); propagateIfChanged( predecessors, predecessors->join(branch, successor.getSuccessorInputs())); - LDBG("Added region branch as predecessor for successor: " << point); + LDBG() << "Added region branch as predecessor for successor: " << point; } } void DeadCodeAnalysis::visitRegionTerminator(Operation *op, RegionBranchOpInterface branch) { - LDBG("visitRegionTerminator: " << *op); + LDBG() << "visitRegionTerminator: " << *op; std::optional<SmallVector<Attribute>> operands = getOperandValues(op); if (!operands) return; @@ -488,7 +488,7 @@ void DeadCodeAnalysis::visitRegionTerminator(Operation *op, auto *state = getOrCreate<Executable>(getProgramPointBefore(®ion->front())); propagateIfChanged(state, state->setToLive()); - LDBG("Marked region entry block live for region: " << region); + LDBG() << "Marked region entry block live for region: " << region; predecessors = getOrCreate<PredecessorState>( getProgramPointBefore(®ion->front())); } else { @@ -498,14 +498,14 @@ void DeadCodeAnalysis::visitRegionTerminator(Operation *op, } propagateIfChanged(predecessors, predecessors->join(op, successor.getSuccessorInputs())); - LDBG("Added region terminator as predecessor for successor: " - << (successor.getSuccessor() ? "region entry" : "parent op")); + LDBG() << "Added region terminator as predecessor for successor: " + << (successor.getSuccessor() ? "region entry" : "parent op"); } } void DeadCodeAnalysis::visitCallableTerminator(Operation *op, CallableOpInterface callable) { - LDBG("visitCallableTerminator: " << *op); + LDBG() << "visitCallableTerminator: " << *op; // Add as predecessors to all callsites this return op. auto *callsites = getOrCreateFor<PredecessorState>( getProgramPointAfter(op), getProgramPointAfter(callable)); @@ -516,15 +516,15 @@ void DeadCodeAnalysis::visitCallableTerminator(Operation *op, getOrCreate<PredecessorState>(getProgramPointAfter(predecessor)); if (canResolve) { propagateIfChanged(predecessors, predecessors->join(op)); - LDBG("Added callable terminator as predecessor for callsite: " - << predecessor->getName()); + LDBG() << "Added callable terminator as predecessor for callsite: " + << predecessor->getName(); } else { // If the terminator is not a return-like, then conservatively assume we // can't resolve the predecessor. propagateIfChanged(predecessors, predecessors->setHasUnknownPredecessors()); - LDBG("Could not resolve callable terminator for callsite: " - << predecessor->getName()); + LDBG() << "Could not resolve callable terminator for callsite: " + << predecessor->getName(); } } } diff --git a/mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp b/mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp index 6a12fe3..509f520 100644 --- a/mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp +++ b/mlir/lib/Analysis/DataFlow/LivenessAnalysis.cpp @@ -10,7 +10,7 @@ #include <cassert> #include <mlir/Analysis/DataFlow/LivenessAnalysis.h> -#include <llvm/Support/Debug.h> +#include <llvm/Support/DebugLog.h> #include <mlir/Analysis/DataFlow/SparseAnalysis.h> #include <mlir/Analysis/DataFlow/Utils.h> #include <mlir/Analysis/DataFlowFramework.h> @@ -21,8 +21,6 @@ #include <mlir/Support/LLVM.h> #define DEBUG_TYPE "liveness-analysis" -#define DBGS() (llvm::dbgs() << '[' << DEBUG_TYPE << "] ") -#define LDBG(X) LLVM_DEBUG(DBGS() << X << "\n") using namespace mlir; using namespace mlir::dataflow; @@ -81,16 +79,15 @@ ChangeResult Liveness::meet(const AbstractSparseLattice &other) { LogicalResult LivenessAnalysis::visitOperation(Operation *op, ArrayRef<Liveness *> operands, ArrayRef<const Liveness *> results) { - LLVM_DEBUG(DBGS() << "[visitOperation] Enter: "; - op->print(llvm::dbgs(), OpPrintingFlags().skipRegions()); - llvm::dbgs() << "\n"); + LDBG() << "[visitOperation] Enter: " + << OpWithFlags(op, OpPrintingFlags().skipRegions()); // This marks values of type (1.a) and (4) liveness as "live". if (!isMemoryEffectFree(op) || op->hasTrait<OpTrait::ReturnLike>()) { - LDBG("[visitOperation] Operation has memory effects or is " - "return-like, marking operands live"); + LDBG() << "[visitOperation] Operation has memory effects or is " + "return-like, marking operands live"; for (auto *operand : operands) { - LDBG(" [visitOperation] Marking operand live: " - << operand << " (" << operand->isLive << ")"); + LDBG() << " [visitOperation] Marking operand live: " << operand << " (" + << operand->isLive << ")"; propagateIfChanged(operand, operand->markLive()); } } @@ -99,28 +96,28 @@ LivenessAnalysis::visitOperation(Operation *op, ArrayRef<Liveness *> operands, bool foundLiveResult = false; for (const Liveness *r : results) { if (r->isLive && !foundLiveResult) { - LDBG("[visitOperation] Found live result, " - "meeting all operands with result: " - << r); + LDBG() << "[visitOperation] Found live result, " + "meeting all operands with result: " + << r; // It is assumed that each operand is used to compute each result of an // op. Thus, if at least one result is live, each operand is live. for (Liveness *operand : operands) { - LDBG(" [visitOperation] Meeting operand: " << operand - << " with result: " << r); + LDBG() << " [visitOperation] Meeting operand: " << operand + << " with result: " << r; meet(operand, *r); } foundLiveResult = true; } - LDBG("[visitOperation] Adding dependency for result: " << r << " after op: " - << *op); + LDBG() << "[visitOperation] Adding dependency for result: " << r + << " after op: " << *op; addDependency(const_cast<Liveness *>(r), getProgramPointAfter(op)); } return success(); } void LivenessAnalysis::visitBranchOperand(OpOperand &operand) { - LDBG("Visiting branch operand: " << operand.get() - << " in op: " << *operand.getOwner()); + LDBG() << "Visiting branch operand: " << operand.get() + << " in op: " << *operand.getOwner(); // We know (at the moment) and assume (for the future) that `operand` is a // non-forwarded branch operand of a `RegionBranchOpInterface`, // `BranchOpInterface`, `RegionBranchTerminatorOpInterface` or return-like op. @@ -152,9 +149,9 @@ void LivenessAnalysis::visitBranchOperand(OpOperand &operand) { for (Value result : op->getResults()) { if (getLatticeElement(result)->isLive) { mayLive = true; - LDBG("[visitBranchOperand] Non-forwarded branch " - "operand may be live due to live result: " - << result); + LDBG() << "[visitBranchOperand] Non-forwarded branch " + "operand may be live due to live result: " + << result; break; } } @@ -174,8 +171,8 @@ void LivenessAnalysis::visitBranchOperand(OpOperand &operand) { // Therefore, we conservatively consider the non-forwarded operand of the // branch operation may live. mayLive = true; - LDBG("[visitBranchOperand] Non-forwarded branch operand may " - "be live due to branch op interface"); + LDBG() << "[visitBranchOperand] Non-forwarded branch operand may " + "be live due to branch op interface"; } else { Operation *parentOp = op->getParentOp(); assert(isa<RegionBranchOpInterface>(parentOp) && @@ -191,9 +188,9 @@ void LivenessAnalysis::visitBranchOperand(OpOperand &operand) { for (Value result : parentOp->getResults()) { if (getLatticeElement(result)->isLive) { mayLive = true; - LDBG("[visitBranchOperand] Non-forwarded branch " - "operand may be live due to parent live result: " - << result); + LDBG() << "[visitBranchOperand] Non-forwarded branch " + "operand may be live due to parent live result: " + << result; break; } } @@ -214,9 +211,9 @@ void LivenessAnalysis::visitBranchOperand(OpOperand &operand) { for (Operation &nestedOp : *block) { if (!isMemoryEffectFree(&nestedOp)) { mayLive = true; - LDBG("Non-forwarded branch operand may be " - "live due to memory effect in block: " - << block); + LDBG() << "Non-forwarded branch operand may be " + "live due to memory effect in block: " + << block; break; } } @@ -224,7 +221,7 @@ void LivenessAnalysis::visitBranchOperand(OpOperand &operand) { if (mayLive) { Liveness *operandLiveness = getLatticeElement(operand.get()); - LDBG("Marking branch operand live: " << operand.get()); + LDBG() << "Marking branch operand live: " << operand.get(); propagateIfChanged(operandLiveness, operandLiveness->markLive()); } @@ -236,7 +233,7 @@ void LivenessAnalysis::visitBranchOperand(OpOperand &operand) { SmallVector<const Liveness *, 4> resultsLiveness; for (const Value result : op->getResults()) resultsLiveness.push_back(getLatticeElement(result)); - LDBG("Visiting operation for non-forwarded branch operand: " << *op); + LDBG() << "Visiting operation for non-forwarded branch operand: " << *op; (void)visitOperation(op, operandLiveness, resultsLiveness); // We also visit the parent op with the parent's results and this operand if @@ -249,14 +246,14 @@ void LivenessAnalysis::visitBranchOperand(OpOperand &operand) { SmallVector<const Liveness *, 4> parentResultsLiveness; for (const Value parentResult : parentOp->getResults()) parentResultsLiveness.push_back(getLatticeElement(parentResult)); - LDBG("Visiting parent operation for non-forwarded branch operand: " - << *parentOp); + LDBG() << "Visiting parent operation for non-forwarded branch operand: " + << *parentOp; (void)visitOperation(parentOp, operandLiveness, parentResultsLiveness); } void LivenessAnalysis::visitCallOperand(OpOperand &operand) { - LDBG("Visiting call operand: " << operand.get() - << " in op: " << *operand.getOwner()); + LDBG() << "Visiting call operand: " << operand.get() + << " in op: " << *operand.getOwner(); // We know (at the moment) and assume (for the future) that `operand` is a // non-forwarded call operand of an op implementing `CallOpInterface`. assert(isa<CallOpInterface>(operand.getOwner()) && @@ -269,18 +266,18 @@ void LivenessAnalysis::visitCallOperand(OpOperand &operand) { // This marks values of type (1.c) liveness as "live". A non-forwarded // call operand is live. Liveness *operandLiveness = getLatticeElement(operand.get()); - LDBG("Marking call operand live: " << operand.get()); + LDBG() << "Marking call operand live: " << operand.get(); propagateIfChanged(operandLiveness, operandLiveness->markLive()); } void LivenessAnalysis::setToExitState(Liveness *lattice) { - LDBG("setToExitState for lattice: " << lattice); + LDBG() << "setToExitState for lattice: " << lattice; if (lattice->isLive) { - LDBG("Lattice already live, nothing to do"); + LDBG() << "Lattice already live, nothing to do"; return; } // This marks values of type (2) liveness as "live". - LDBG("Marking lattice live due to exit state"); + LDBG() << "Marking lattice live due to exit state"; (void)lattice->markLive(); propagateIfChanged(lattice, ChangeResult::Change); } @@ -290,14 +287,14 @@ void LivenessAnalysis::setToExitState(Liveness *lattice) { //===----------------------------------------------------------------------===// RunLivenessAnalysis::RunLivenessAnalysis(Operation *op) { - LDBG("Constructing RunLivenessAnalysis for op: " << op->getName()); + LDBG() << "Constructing RunLivenessAnalysis for op: " << op->getName(); SymbolTableCollection symbolTable; loadBaselineAnalyses(solver); solver.load<LivenessAnalysis>(symbolTable); - LDBG("Initializing and running solver"); + LDBG() << "Initializing and running solver"; (void)solver.initializeAndRun(op); - LDBG("Dumping liveness state for op"); + LDBG() << "RunLivenessAnalysis initialized for op: " << op->getName(); } const Liveness *RunLivenessAnalysis::getLiveness(Value val) { |