[Mlir-commits] [mlir] [mlir] Fix `--mlir-print-ir-tree-dir` when the symbol name contains `/` (PR #137686)
Mehdi Amini
llvmlistbot at llvm.org
Mon Apr 28 14:47:22 PDT 2025
================
@@ -210,22 +211,25 @@ struct BasicIRPrinterConfig : public PassManager::IRPrinterConfig {
/// `op` first, `op` last). This information is used to construct the directory
/// tree for the `FileTreeIRPrinterConfig` below.
/// The counter for `op` will be incremented by this call.
-static std::pair<SmallVector<std::pair<std::string, StringRef>>, std::string>
+static std::pair<SmallVector<std::pair<std::string, std::string>>, std::string>
getOpAndSymbolNames(Operation *op, StringRef passName,
llvm::DenseMap<Operation *, unsigned> &counters) {
- SmallVector<std::pair<std::string, StringRef>> pathElements;
+ SmallVector<std::pair<std::string, std::string>> pathElements;
SmallVector<unsigned> countPrefix;
Operation *iter = op;
++counters.try_emplace(op, -1).first->second;
while (iter) {
countPrefix.push_back(counters[iter]);
- StringAttr symbolName =
+ StringAttr symbolNameAttr =
iter->getAttrOfType<StringAttr>(SymbolTable::getSymbolAttrName());
+ std::string symbolName =
+ symbolNameAttr ? symbolNameAttr.str() : "no-symbol-name";
+ llvm::replace(symbolName, '/', '_');
----------------
joker-eph wrote:
Thanks!
I pushed a change to the test, trying to make the windows build fail first (since I can't test it myself), assuming the test fails I'll then push an update to fix it.
https://github.com/llvm/llvm-project/pull/137686
More information about the Mlir-commits
mailing list