[Mlir-commits] [mlir] [mlir][debug] Support DIGenericSubrange. (PR #113441)
Tobias Gysi
llvmlistbot at llvm.org
Wed Oct 30 08:11:10 PDT 2024
================
@@ -309,6 +309,35 @@ DICommonBlockAttr DebugImporter::translateImpl(llvm::DICommonBlock *node) {
translate(node->getFile()), node->getLineNo());
}
+DIGenericSubrangeAttr
+DebugImporter::translateImpl(llvm::DIGenericSubrange *node) {
+ auto getAttrOrNull =
+ [&](llvm::DIGenericSubrange::BoundType data) -> Attribute {
+ if (data.isNull())
+ return nullptr;
+ if (auto *expr = dyn_cast<llvm::DIExpression *>(data))
+ return translateExpression(expr);
+ if (auto *var = dyn_cast<llvm::DIVariable *>(data)) {
+ if (auto *local = dyn_cast<llvm::DILocalVariable>(var))
+ return translate(local);
+ if (auto *global = dyn_cast<llvm::DIGlobalVariable>(var))
+ return translate(global);
+ return nullptr;
+ }
+ return nullptr;
+ };
+ Attribute count = getAttrOrNull(node->getCount());
+ Attribute upperBound = getAttrOrNull(node->getUpperBound());
+ Attribute lowerBound = getAttrOrNull(node->getLowerBound());
+ Attribute stride = getAttrOrNull(node->getStride());
+ // DIGenericSubrangeAttr requires lowerBound, stride and one of count or
+ // upperBound.
+ if (!lowerBound || !stride || (!count && !upperBound))
+ return {};
----------------
gysit wrote:
```suggestion
// Either count or the upper bound needs to be present. Otherwise, the
// metadata is invalid.
if (!count && !upperBound)
return {};
```
Should we just check either count or upper bound is set here as above? I assume the attribute verifier checks the other two are non-null?
https://github.com/llvm/llvm-project/pull/113441
More information about the Mlir-commits
mailing list