[Mlir-commits] [mlir] [mlir] Add support for DIGlobalVariable and DIGlobalVariableExpression (PR #73367)

Justin Wilson llvmlistbot at llvm.org
Sat Nov 25 08:34:53 PST 2023


================
@@ -23,15 +23,24 @@
 namespace mlir {
 namespace LLVM {
 
-/// This class represents the base attribute for all debug info attributes.
-class DINodeAttr : public Attribute {
+/// This class represents the base attribute for all metadata attributes.
+class MDNodeAttr : public Attribute {
----------------
waj334 wrote:

`Ah I see, MDNode sounds like it is any metadata node?`

MDNode is the base for all debug information in LLVM (https://llvm.org/doxygen/classllvm_1_1Metadata.html).

` It feels like Attribute is the direct counterpart for it in MLIR (and we probably don't want to replicate it)?`

Maybe. I implemented it this just to follow convention without breaking what was there before.

`DILocation, which also derives from MDNode, is translated with a separate function in the debug info translation so maybe this would be the right approach for DIGlobalVariableExpression and DIExpression?`

I feel like this is a slippery slope (you let one slide, then you have to let them all slide). The implementation of DILocation seemed like a means to an end as it probably would've been the only one-off at the time of implementing DINode.

```
MDNodeAttr translate(llvm::DINode *node) {
  return translate(cast<llvm::MDNode>(node));
}
```

I can template this method and, in theory, any debug information could be supported.

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


More information about the Mlir-commits mailing list