[flang-commits] [flang] [mlir] [mlir] add option to print SSA IDs using `NameLoc`s as prefixes (PR #119996)

Maksim Levental via flang-commits flang-commits at lists.llvm.org
Mon Dec 16 07:27:13 PST 2024


================
@@ -1553,7 +1570,12 @@ void SSANameState::numberValuesInBlock(Block &block) {
       specialNameBuffer.resize(strlen("arg"));
       specialName << nextArgumentID++;
     }
-    setValueName(arg, specialName.str());
+    if (printerFlags.shouldUseNameLocAsPrefix() && isa<NameLoc>(arg.getLoc())) {
+      auto nameLoc = cast<NameLoc>(arg.getLoc());
+      setValueName(arg, nameLoc.getName());
----------------
makslevental wrote:

I tried to factor out the whole conditional but then you end up hiding the `printerFlags.shouldUseNameLocAsPrefix()` in the helper itself. I didn't really like that (would be surprising I think) so I factored out the "get the name from a (possibly) nested `NameLoc`".


https://github.com/llvm/llvm-project/pull/119996


More information about the flang-commits mailing list