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

River Riddle via flang-commits flang-commits at lists.llvm.org
Mon Dec 16 00:24:51 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());
----------------
River707 wrote:

Can you share the implementation of these three usages? Seems like they all pretty much have the same pattern.

Also for the NameLoc itself, you likely want to use `arg.getLoc().findInstanceOf<NameLoc>()`, given that in some cases (e.g. DebugInfo) you may not have a top level NameLoc.

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


More information about the flang-commits mailing list