[Mlir-commits] [mlir] [MLIR][LLVM] More on CG Profile: support null function entries (PR #137269)

Tobias Gysi llvmlistbot at llvm.org
Sun Apr 27 23:47:04 PDT 2025


================
@@ -1370,10 +1370,17 @@ def ModuleFlagCGProfileEntryAttr
           ]>]
     ```
   }];
-  let parameters = (ins "FlatSymbolRefAttr":$from,
-                        "FlatSymbolRefAttr":$to,
-                        "uint64_t":$count);
-  let assemblyFormat = "`<` struct(params) `>`";
+  let parameters = (
+    ins OptionalParameter<"std::optional<FlatSymbolRefAttr>">:$from,
+        OptionalParameter<"std::optional<FlatSymbolRefAttr>">:$to,
----------------
gysit wrote:

> When I use OptionalParameter<"FlatSymbolRefAttr">, the printer works successfully but parser fails on to = 

Yeah I would expect that instead of `to = null` you would have to omit the to to get a nullptr.

e.g instead of:
```
 #llvm.cgprofile_entry<from = null, to = @to, count = 222>,
 #llvm.cgprofile_entry<from = @from, to = null, count = 222>,
``
I would expect that the attributes without std:optional would print/parse like this:
```
 #llvm.cgprofile_entry<to = @to, count = 222>,
 #llvm.cgprofile_entry<from = @from, count = 222>,
```
meaning the null symbol references are omitted. 

If you can get it working, it is strongly preferable over implementing our own printer and parser even if the IR looks a bit different than in LLVM IR.



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


More information about the Mlir-commits mailing list