|
10 | 10 | #include "mlir/IR/SymbolTable.h" |
11 | 11 | #include "mlir/Pass/PassManager.h" |
12 | 12 | #include "mlir/Support/FileUtilities.h" |
| 13 | +#include "llvm/ADT/STLExtras.h" |
13 | 14 | #include "llvm/ADT/StringExtras.h" |
14 | 15 | #include "llvm/Support/FileSystem.h" |
15 | 16 | #include "llvm/Support/FormatVariadic.h" |
@@ -210,22 +211,26 @@ struct BasicIRPrinterConfig : public PassManager::IRPrinterConfig { |
210 | 211 | /// `op` first, `op` last). This information is used to construct the directory |
211 | 212 | /// tree for the `FileTreeIRPrinterConfig` below. |
212 | 213 | /// The counter for `op` will be incremented by this call. |
213 | | -static std::pair<SmallVector<std::pair<std::string, StringRef>>, std::string> |
| 214 | +static std::pair<SmallVector<std::pair<std::string, std::string>>, std::string> |
214 | 215 | getOpAndSymbolNames(Operation *op, StringRef passName, |
215 | 216 | llvm::DenseMap<Operation *, unsigned> &counters) { |
216 | | - SmallVector<std::pair<std::string, StringRef>> pathElements; |
| 217 | + SmallVector<std::pair<std::string, std::string>> pathElements; |
217 | 218 | SmallVector<unsigned> countPrefix; |
218 | 219 |
|
219 | 220 | Operation *iter = op; |
220 | 221 | ++counters.try_emplace(op, -1).first->second; |
221 | 222 | while (iter) { |
222 | 223 | countPrefix.push_back(counters[iter]); |
223 | | - StringAttr symbolName = |
| 224 | + StringAttr symbolNameAttr = |
224 | 225 | iter->getAttrOfType<StringAttr>(SymbolTable::getSymbolAttrName()); |
| 226 | + std::string symbolName = |
| 227 | + symbolNameAttr ? symbolNameAttr.str() : "no-symbol-name"; |
| 228 | + llvm::replace(symbolName, '/', '_'); |
| 229 | + llvm::replace(symbolName, '\\', '_'); |
| 230 | + |
225 | 231 | std::string opName = |
226 | 232 | llvm::join(llvm::split(iter->getName().getStringRef().str(), '.'), "_"); |
227 | | - pathElements.emplace_back(opName, symbolName ? symbolName.strref() |
228 | | - : "no-symbol-name"); |
| 233 | + pathElements.emplace_back(std::move(opName), std::move(symbolName)); |
229 | 234 | iter = iter->getParentOp(); |
230 | 235 | } |
231 | 236 | // Return in the order of top level (module) down to `op`. |
|
0 commit comments