forked from OSchip/llvm-project
[mlir][AsmPrinter] Change value numbering for local scope to be the next isolated operation.
Summary: This revision updates the value numbering when printing to number from the next parent operation that is isolated from above. This is the highest level to number from that still ensures thread-safety. This revision also changes the behavior of Operator::operator<< to use local scope to avoid thread races when numbering operations. Differential Revision: https://reviews.llvm.org/D77525
This commit is contained in:
parent
0731132888
commit
ae9edbcea2
|
@ -605,7 +605,7 @@ private:
|
||||||
};
|
};
|
||||||
|
|
||||||
inline raw_ostream &operator<<(raw_ostream &os, Operation &op) {
|
inline raw_ostream &operator<<(raw_ostream &os, Operation &op) {
|
||||||
op.print(os);
|
op.print(os, OpPrintingFlags().useLocalScope());
|
||||||
return os;
|
return os;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2344,23 +2344,23 @@ void Value::printAsOperand(raw_ostream &os, AsmState &state) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Operation::print(raw_ostream &os, OpPrintingFlags flags) {
|
void Operation::print(raw_ostream &os, OpPrintingFlags flags) {
|
||||||
// Handle top-level operations or local printing.
|
// Find the operation to number from based upon the provided flags.
|
||||||
if (!getParent() || flags.shouldUseLocalScope()) {
|
Operation *printedOp = this;
|
||||||
AsmState state(this);
|
bool shouldUseLocalScope = flags.shouldUseLocalScope();
|
||||||
OperationPrinter(os, flags, state.getImpl()).print(this);
|
do {
|
||||||
return;
|
// If we are printing local scope, stop at the first operation that is
|
||||||
}
|
// isolated from above.
|
||||||
|
if (shouldUseLocalScope && printedOp->isKnownIsolatedFromAbove())
|
||||||
|
break;
|
||||||
|
|
||||||
Operation *parentOp = getParentOp();
|
// Otherwise, traverse up to the next parent.
|
||||||
if (!parentOp) {
|
Operation *parentOp = printedOp->getParentOp();
|
||||||
os << "<<UNLINKED OPERATION>>\n";
|
if (!parentOp)
|
||||||
return;
|
break;
|
||||||
}
|
printedOp = parentOp;
|
||||||
// Get the top-level op.
|
} while (true);
|
||||||
while (auto *nextOp = parentOp->getParentOp())
|
|
||||||
parentOp = nextOp;
|
|
||||||
|
|
||||||
AsmState state(parentOp);
|
AsmState state(printedOp);
|
||||||
print(os, state, flags);
|
print(os, state, flags);
|
||||||
}
|
}
|
||||||
void Operation::print(raw_ostream &os, AsmState &state, OpPrintingFlags flags) {
|
void Operation::print(raw_ostream &os, AsmState &state, OpPrintingFlags flags) {
|
||||||
|
|
Loading…
Reference in New Issue