[Mlir-commits] [mlir] [MLIR][LLVM] Attach kernel metadata representation to `llvm.func` (PR #101314)

Tobias Gysi llvmlistbot at llvm.org
Thu Aug 1 02:40:34 PDT 2024


================
@@ -226,6 +241,129 @@ static LogicalResult setNoaliasScopesAttr(const llvm::MDNode *node,
   return success();
 }
 
+/// Extract constant integer value from metadata if this is constant. Return
+/// `std::nullopt` otherwise.
+static std::optional<int32_t> parseIntegerMD(llvm::Metadata *md) {
+  auto *c = llvm::dyn_cast_or_null<llvm::ConstantAsMetadata>(md);
----------------
gysit wrote:

```suggestion
  auto *constant = dyn_cast_if_present<llvm::ConstantAsMetadata>(md);
```
nit: Let's avoid single letter variable names and I believe dyn_cast_if_present is the more modern version of dyn_cast_or_null.

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


More information about the Mlir-commits mailing list