[Mlir-commits] [mlir] [mlir] Add support for DIGlobalVariable and DIGlobalVariableExpression (PR #73367)
Christian Ulmann
llvmlistbot at llvm.org
Wed Nov 29 00:53:41 PST 2023
================
@@ -281,8 +293,31 @@ Location DebugImporter::translateLoc(llvm::DILocation *loc) {
return result;
}
+DIExpressionAttr DebugImporter::translateExpression(llvm::DIExpression *node) {
+ SmallVector<DIExpressionElemAttr> ops;
+
+ // Begin processing the operations
+ for (const auto &op : node->expr_ops()) {
+ SmallVector<uint64_t> operands;
+ operands.reserve(op.getNumArgs());
+ for (const auto &i : llvm::seq(op.getNumArgs())) {
+ operands.push_back(op.getArg(i));
+ }
+ const auto attr = DIExpressionElemAttr::get(context, op.getOp(), operands);
+ ops.push_back(attr);
+ }
+ return DIExpressionAttr::get(context, ops);
+}
+
+DIGlobalVariableExpressionAttr DebugImporter::translateGlobalVariableExpression(
+ llvm::DIGlobalVariableExpression *node) {
+ return DIGlobalVariableExpressionAttr::get(
+ context, translate(node->getVariable()),
+ translateExpression(node->getExpression()));
+}
+
StringAttr DebugImporter::getStringAttrOrNull(llvm::MDString *stringNode) {
if (!stringNode)
return StringAttr();
return StringAttr::get(context, stringNode->getString());
-}
+}
----------------
Dinistro wrote:
Nit: Missing newline. This seems to be a CLion thing, IIRC.
https://github.com/llvm/llvm-project/pull/73367
More information about the Mlir-commits
mailing list