MLIR 24.0.0git
DebugImporter.cpp
Go to the documentation of this file.
1//===- DebugImporter.cpp - LLVM to MLIR Debug conversion ------------------===//
2//
3// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4// See https://llvm.org/LICENSE.txt for license information.
5// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6//
7//===----------------------------------------------------------------------===//
8
9#include "DebugImporter.h"
11#include "mlir/IR/Attributes.h"
13#include "mlir/IR/Location.h"
14#include "llvm/ADT/STLExtras.h"
15#include "llvm/ADT/TypeSwitch.h"
16#include "llvm/BinaryFormat/Dwarf.h"
17#include "llvm/IR/Constants.h"
18#include "llvm/IR/DebugInfoMetadata.h"
19#include "llvm/IR/Metadata.h"
20
21using namespace mlir;
22using namespace mlir::LLVM;
23using namespace mlir::LLVM::detail;
24
25DebugImporter::DebugImporter(ModuleOp mlirModule,
26 bool dropDICompositeTypeElements)
27 : cache([&](llvm::DINode *node) { return createRecSelf(node); }),
28 context(mlirModule.getContext()), mlirModule(mlirModule),
29 dropDICompositeTypeElements(dropDICompositeTypeElements) {}
30
32 llvm::DISubprogram *subprogram = func->getSubprogram();
33 if (!subprogram)
34 return UnknownLoc::get(context);
35
36 // Add a fused location to link the subprogram information.
37 StringAttr fileName = StringAttr::get(context, subprogram->getFilename());
39 {FileLineColLoc::get(fileName, subprogram->getLine(), /*column=*/0)},
40 translate(subprogram), context);
41}
42
43//===----------------------------------------------------------------------===//
44// Attributes
45//===----------------------------------------------------------------------===//
46
47DIBasicTypeAttr DebugImporter::translateImpl(llvm::DIBasicType *node) {
48 return DIBasicTypeAttr::get(context, node->getTag(),
49 getStringAttrOrNull(node->getRawName()),
50 node->getSizeInBits(), node->getEncoding());
51}
52
53DICompileUnitAttr DebugImporter::translateImpl(llvm::DICompileUnit *node) {
54 std::optional<DIEmissionKind> emissionKind =
55 symbolizeDIEmissionKind(node->getEmissionKind());
56 std::optional<DINameTableKind> nameTableKind = symbolizeDINameTableKind(
57 static_cast<
58 std::underlying_type_t<llvm::DICompileUnit::DebugNameTableKind>>(
59 node->getNameTableKind()));
61 if (node->getImportedEntities()) {
62 for (llvm::DIImportedEntity *importedEntity : node->getImportedEntities())
63 if (DINodeAttr nodeAttr =
64 translate(static_cast<llvm::DINode *>(importedEntity)))
65 imports.push_back(nodeAttr);
66 }
67 llvm::DISourceLanguageName sourceLanguage = node->getSourceLanguage();
68 DISourceLanguageNameAttr sourceLanguageAttr;
69 if (sourceLanguage.hasVersionedName()) {
70 sourceLanguageAttr = DISourceLanguageNameAttr::get(
71 context, /*language=*/0, sourceLanguage.getName(),
72 sourceLanguage.getVersion(), sourceLanguage.getDialect());
73 } else {
74 sourceLanguageAttr = DISourceLanguageNameAttr::get(
75 context, sourceLanguage.getName(), /*name=*/0,
76 /*version=*/std::nullopt, sourceLanguage.getDialect());
77 }
78 return DICompileUnitAttr::get(
79 context, /*recId=*/DistinctAttr{}, /*isRecSelf=*/false,
80 getOrCreateDistinctID(node), sourceLanguageAttr,
81 translate(node->getFile()), getStringAttrOrNull(node->getRawProducer()),
82 node->isOptimized(), emissionKind.value(),
83 node->isDebugInfoForProfiling(), nameTableKind.value(),
84 getStringAttrOrNull(node->getRawSplitDebugFilename()), imports);
85}
86
87DICompositeTypeAttr DebugImporter::translateImpl(llvm::DICompositeType *node) {
88 std::optional<DIFlags> flags = symbolizeDIFlags(node->getFlags());
89 SmallVector<DINodeAttr> elements;
90
91 // A vector always requires an element.
92 bool isVectorType = flags && bitEnumContainsAll(*flags, DIFlags::Vector);
93 if (isVectorType || !dropDICompositeTypeElements) {
94 for (llvm::DINode *element : node->getElements()) {
95 assert(element && "expected a non-null element type");
96 elements.push_back(translate(element));
97 }
98 }
99 // Drop the elements parameter if any of the elements are invalid.
100 if (llvm::is_contained(elements, nullptr))
101 elements.clear();
102 DITypeAttr baseType = translate(node->getBaseType());
103 // Arrays require a base type, otherwise the debug metadata is considered to
104 // be malformed.
105 if (node->getTag() == llvm::dwarf::DW_TAG_array_type && !baseType)
106 return nullptr;
107 return DICompositeTypeAttr::get(
108 context, node->getTag(), getStringAttrOrNull(node->getRawName()),
109 translate(node->getFile()), node->getLine(), translate(node->getScope()),
110 baseType, flags.value_or(DIFlags::Zero), node->getSizeInBits(),
111 node->getAlignInBits(), translateExpression(node->getDataLocationExp()),
112 translateExpression(node->getRankExp()),
113 translateExpression(node->getAllocatedExp()),
114 translateExpression(node->getAssociatedExp()),
115 getStringAttrOrNull(node->getRawIdentifier()),
116 translate(node->getDiscriminator()), elements);
117}
118
119DIDerivedTypeAttr DebugImporter::translateImpl(llvm::DIDerivedType *node) {
120 // Return nullptr if the base type is invalid.
121 DITypeAttr baseType = translate(node->getBaseType());
122 if (node->getBaseType() && !baseType)
123 return nullptr;
124 llvm::Metadata *rawExtraData = node->getExtraData();
125 Attribute extraData;
126 if (auto *extraDataNode = dyn_cast_or_null<llvm::DINode>(rawExtraData)) {
127 extraData = translate(extraDataNode);
128 } else if (auto *constantAsMetadata =
129 dyn_cast_or_null<llvm::ConstantAsMetadata>(rawExtraData)) {
130 if (auto *constantInt =
131 dyn_cast<llvm::ConstantInt>(constantAsMetadata->getValue())) {
132 const APInt &value = constantInt->getValue();
133 extraData = IntegerAttr::get(
134 IntegerType::get(context, value.getBitWidth()), value);
135 }
136 }
137 return DIDerivedTypeAttr::get(
138 context, node->getTag(), getStringAttrOrNull(node->getRawName()),
139 translate(node->getFile()), node->getLine(), translate(node->getScope()),
140 baseType, node->getSizeInBits(), node->getAlignInBits(),
141 node->getOffsetInBits(), node->getDWARFAddressSpace(),
142 symbolizeDIFlags(node->getFlags()).value_or(DIFlags::Zero), extraData);
143}
144
145DIStringTypeAttr DebugImporter::translateImpl(llvm::DIStringType *node) {
146 return DIStringTypeAttr::get(
147 context, node->getTag(), getStringAttrOrNull(node->getRawName()),
148 node->getSizeInBits(), node->getAlignInBits(),
149 translate(node->getStringLength()),
150 translateExpression(node->getStringLengthExp()),
151 translateExpression(node->getStringLocationExp()), node->getEncoding());
152}
153
154DIFileAttr DebugImporter::translateImpl(llvm::DIFile *node) {
155 return DIFileAttr::get(context, node->getFilename(), node->getDirectory());
156}
157
158DILabelAttr DebugImporter::translateImpl(llvm::DILabel *node) {
159 // Return nullptr if the scope or type is a cyclic dependency.
160 DIScopeAttr scope = translate(node->getScope());
161 if (node->getScope() && !scope)
162 return nullptr;
163 return DILabelAttr::get(context, scope,
164 getStringAttrOrNull(node->getRawName()),
165 translate(node->getFile()), node->getLine());
166}
167
168DILexicalBlockAttr DebugImporter::translateImpl(llvm::DILexicalBlock *node) {
169 // Return nullptr if the scope or type is a cyclic dependency.
170 DIScopeAttr scope = translate(node->getScope());
171 if (node->getScope() && !scope)
172 return nullptr;
173 return DILexicalBlockAttr::get(context, scope, translate(node->getFile()),
174 node->getLine(), node->getColumn());
175}
176
177DILexicalBlockFileAttr
178DebugImporter::translateImpl(llvm::DILexicalBlockFile *node) {
179 // Return nullptr if the scope or type is a cyclic dependency.
180 DIScopeAttr scope = translate(node->getScope());
181 if (node->getScope() && !scope)
182 return nullptr;
183 return DILexicalBlockFileAttr::get(context, scope, translate(node->getFile()),
184 node->getDiscriminator());
185}
186
187DIGlobalVariableAttr
188DebugImporter::translateImpl(llvm::DIGlobalVariable *node) {
189 // Names of DIGlobalVariables can be empty. MLIR models them as null, instead
190 // of empty strings, so this special handling is necessary.
191 auto convertToStringAttr = [&](StringRef name) -> StringAttr {
192 if (name.empty())
193 return {};
194 return StringAttr::get(context, node->getName());
195 };
196 return DIGlobalVariableAttr::get(
197 context, translate(node->getScope()),
198 convertToStringAttr(node->getName()),
199 convertToStringAttr(node->getLinkageName()), translate(node->getFile()),
200 node->getLine(), translate(node->getType()), node->isLocalToUnit(),
201 node->isDefinition(), node->getAlignInBits());
202}
203
204DILocalVariableAttr DebugImporter::translateImpl(llvm::DILocalVariable *node) {
205 // Return nullptr if the scope or type is a cyclic dependency.
206 DIScopeAttr scope = translate(node->getScope());
207 if (node->getScope() && !scope)
208 return nullptr;
209 return DILocalVariableAttr::get(
210 context, scope, getStringAttrOrNull(node->getRawName()),
211 translate(node->getFile()), node->getLine(), node->getArg(),
212 node->getAlignInBits(), translate(node->getType()),
213 symbolizeDIFlags(node->getFlags()).value_or(DIFlags::Zero));
214}
215
216DIVariableAttr DebugImporter::translateImpl(llvm::DIVariable *node) {
217 return cast<DIVariableAttr>(translate(static_cast<llvm::DINode *>(node)));
218}
219
220DIScopeAttr DebugImporter::translateImpl(llvm::DIScope *node) {
221 return cast<DIScopeAttr>(translate(static_cast<llvm::DINode *>(node)));
222}
223
224DIModuleAttr DebugImporter::translateImpl(llvm::DIModule *node) {
225 return DIModuleAttr::get(
226 context, translate(node->getFile()), translate(node->getScope()),
227 getStringAttrOrNull(node->getRawName()),
228 getStringAttrOrNull(node->getRawConfigurationMacros()),
229 getStringAttrOrNull(node->getRawIncludePath()),
230 getStringAttrOrNull(node->getRawAPINotesFile()), node->getLineNo(),
231 node->getIsDecl());
232}
233
234DINamespaceAttr DebugImporter::translateImpl(llvm::DINamespace *node) {
235 return DINamespaceAttr::get(context, getStringAttrOrNull(node->getRawName()),
236 translate(node->getScope()),
237 node->getExportSymbols());
238}
239
240DIImportedEntityAttr
241DebugImporter::translateImpl(llvm::DIImportedEntity *node) {
242 SmallVector<DINodeAttr> elements;
243 for (llvm::DINode *element : node->getElements()) {
244 assert(element && "expected a non-null element type");
245 elements.push_back(translate(element));
246 }
247
248 return DIImportedEntityAttr::get(
249 context, node->getTag(), translate(node->getScope()),
250 translate(node->getEntity()), translate(node->getFile()), node->getLine(),
251 getStringAttrOrNull(node->getRawName()), elements);
252}
253
254DISubprogramAttr DebugImporter::translateImpl(llvm::DISubprogram *node) {
255 // Only definitions require a distinct identifier.
256 mlir::DistinctAttr id;
257 if (node->isDistinct())
258 id = getOrCreateDistinctID(node);
259
260 // Return nullptr if the scope or type is invalid.
261 DIScopeAttr scope = translate(node->getScope());
262 if (node->getScope() && !scope)
263 return nullptr;
264 std::optional<DISubprogramFlags> subprogramFlags =
265 symbolizeDISubprogramFlags(node->getSubprogram()->getSPFlags());
266 assert(subprogramFlags && "expected valid subprogram flags");
267 DISubroutineTypeAttr type = translate(node->getType());
268 if (node->getType() && !type)
269 return nullptr;
270
271 // Convert the retained nodes but drop all of them if one of them is invalid.
272 SmallVector<Attribute> retainedNodes;
273 auto add = [this, &retainedNodes](llvm::DINode *retainedNode) {
274 retainedNodes.push_back(translate(retainedNode));
275 };
276 auto addGVE = [](llvm::DIGlobalVariableExpression *GVE) {
277 // FIXME Import DIGlobalVariableExpressions from retainedNodes without
278 // duplicating them.
279 };
280 node->forEachRetainedNode(add, add, add, add, addGVE);
281 if (llvm::is_contained(retainedNodes, nullptr))
282 retainedNodes.clear();
283
284 SmallVector<DINodeAttr> annotations;
285 // We currently only support `string` values for annotations on the MLIR side.
286 // Theoretically we could support other primitives, but LLVM is not using
287 // other types in practice.
288 if (llvm::DINodeArray rawAnns = node->getAnnotations(); rawAnns) {
289 for (size_t i = 0, e = rawAnns->getNumOperands(); i < e; ++i) {
290 const llvm::MDTuple *tuple = cast<llvm::MDTuple>(rawAnns->getOperand(i));
291 if (tuple->getNumOperands() != 2)
292 continue;
293 const llvm::MDString *name = cast<llvm::MDString>(tuple->getOperand(0));
294 const llvm::MDString *value =
295 dyn_cast<llvm::MDString>(tuple->getOperand(1));
296 if (name && value) {
297 annotations.push_back(DIAnnotationAttr::get(
298 context, StringAttr::get(context, name->getString()),
299 StringAttr::get(context, value->getString())));
300 }
301 }
302 }
303
304 return DISubprogramAttr::get(context, id, translate(node->getUnit()), scope,
305 getStringAttrOrNull(node->getRawName()),
306 getStringAttrOrNull(node->getRawLinkageName()),
307 translate(node->getFile()), node->getLine(),
308 node->getScopeLine(), *subprogramFlags, type,
309 retainedNodes, annotations);
310}
311
312DISubrangeAttr DebugImporter::translateImpl(llvm::DISubrange *node) {
313 auto getAttrOrNull = [&](llvm::DISubrange::BoundType data) -> Attribute {
314 if (data.isNull())
315 return nullptr;
316 if (auto *constInt = dyn_cast<llvm::ConstantInt *>(data))
317 return IntegerAttr::get(IntegerType::get(context, 64),
318 constInt->getSExtValue());
319 if (auto *expr = dyn_cast<llvm::DIExpression *>(data))
320 return translateExpression(expr);
321 if (auto *var = dyn_cast<llvm::DIVariable *>(data)) {
322 if (auto *local = dyn_cast<llvm::DILocalVariable>(var))
323 return translate(local);
324 if (auto *global = dyn_cast<llvm::DIGlobalVariable>(var))
325 return translate(global);
326 return nullptr;
327 }
328 return nullptr;
329 };
330 Attribute count = getAttrOrNull(node->getCount());
331 Attribute upperBound = getAttrOrNull(node->getUpperBound());
332 // Either count or the upper bound needs to be present. Otherwise, the
333 // metadata is invalid. The conversion might fail due to unsupported DI nodes.
334 if (!count && !upperBound)
335 return {};
336 return DISubrangeAttr::get(context, count,
337 getAttrOrNull(node->getLowerBound()), upperBound,
338 getAttrOrNull(node->getStride()));
339}
340
341DICommonBlockAttr DebugImporter::translateImpl(llvm::DICommonBlock *node) {
342 return DICommonBlockAttr::get(context, translate(node->getScope()),
343 translate(node->getDecl()),
344 getStringAttrOrNull(node->getRawName()),
345 translate(node->getFile()), node->getLineNo());
346}
347
348DIGenericSubrangeAttr
349DebugImporter::translateImpl(llvm::DIGenericSubrange *node) {
350 auto getAttrOrNull =
351 [&](llvm::DIGenericSubrange::BoundType data) -> Attribute {
352 if (data.isNull())
353 return nullptr;
354 if (auto *expr = dyn_cast<llvm::DIExpression *>(data))
355 return translateExpression(expr);
356 if (auto *var = dyn_cast<llvm::DIVariable *>(data)) {
357 if (auto *local = dyn_cast<llvm::DILocalVariable>(var))
358 return translate(local);
359 if (auto *global = dyn_cast<llvm::DIGlobalVariable>(var))
360 return translate(global);
361 return nullptr;
362 }
363 return nullptr;
364 };
365 Attribute count = getAttrOrNull(node->getCount());
366 Attribute upperBound = getAttrOrNull(node->getUpperBound());
367 Attribute lowerBound = getAttrOrNull(node->getLowerBound());
368 Attribute stride = getAttrOrNull(node->getStride());
369 // Either count or the upper bound needs to be present. Otherwise, the
370 // metadata is invalid.
371 if (!count && !upperBound)
372 return {};
373 return DIGenericSubrangeAttr::get(context, count, lowerBound, upperBound,
374 stride);
375}
376
377DISubroutineTypeAttr
378DebugImporter::translateImpl(llvm::DISubroutineType *node) {
379 SmallVector<DITypeAttr> types;
380 for (llvm::DIType *type : node->getTypeArray()) {
381 if (!type) {
382 // A nullptr entry may appear at the beginning or the end of the
383 // subroutine types list modeling either a void result type or the type of
384 // a variadic argument. Translate the nullptr to an explicit
385 // DINullTypeAttr since the attribute list cannot contain a nullptr entry.
386 types.push_back(DINullTypeAttr::get(context));
387 continue;
388 }
389 types.push_back(translate(type));
390 }
391 // Return nullptr if any of the types is invalid.
392 if (llvm::is_contained(types, nullptr))
393 return nullptr;
394 return DISubroutineTypeAttr::get(context, node->getCC(), types);
395}
396
397DITypeAttr DebugImporter::translateImpl(llvm::DIType *node) {
398 return cast<DITypeAttr>(translate(static_cast<llvm::DINode *>(node)));
399}
400
402 if (!node)
403 return nullptr;
404
405 // Check for a cached instance.
406 auto cacheEntry = cache.lookupOrInit(node);
407 if (std::optional<DINodeAttr> result = cacheEntry.get())
408 return *result;
409
410 // Convert the debug metadata if possible.
411 auto translateNode = [this](llvm::DINode *node) -> DINodeAttr {
412 if (auto *casted = dyn_cast<llvm::DIBasicType>(node))
413 return translateImpl(casted);
414 if (auto *casted = dyn_cast<llvm::DICommonBlock>(node))
415 return translateImpl(casted);
416 if (auto *casted = dyn_cast<llvm::DICompileUnit>(node))
417 return translateImpl(casted);
418 if (auto *casted = dyn_cast<llvm::DICompositeType>(node))
419 return translateImpl(casted);
420 if (auto *casted = dyn_cast<llvm::DIDerivedType>(node))
421 return translateImpl(casted);
422 if (auto *casted = dyn_cast<llvm::DIStringType>(node))
423 return translateImpl(casted);
424 if (auto *casted = dyn_cast<llvm::DIFile>(node))
425 return translateImpl(casted);
426 if (auto *casted = dyn_cast<llvm::DIGlobalVariable>(node))
427 return translateImpl(casted);
428 if (auto *casted = dyn_cast<llvm::DIImportedEntity>(node))
429 return translateImpl(casted);
430 if (auto *casted = dyn_cast<llvm::DILabel>(node))
431 return translateImpl(casted);
432 if (auto *casted = dyn_cast<llvm::DILexicalBlock>(node))
433 return translateImpl(casted);
434 if (auto *casted = dyn_cast<llvm::DILexicalBlockFile>(node))
435 return translateImpl(casted);
436 if (auto *casted = dyn_cast<llvm::DILocalVariable>(node))
437 return translateImpl(casted);
438 if (auto *casted = dyn_cast<llvm::DIModule>(node))
439 return translateImpl(casted);
440 if (auto *casted = dyn_cast<llvm::DINamespace>(node))
441 return translateImpl(casted);
442 if (auto *casted = dyn_cast<llvm::DISubprogram>(node))
443 return translateImpl(casted);
444 if (auto *casted = dyn_cast<llvm::DISubrange>(node))
445 return translateImpl(casted);
446 if (auto *casted = dyn_cast<llvm::DIGenericSubrange>(node))
447 return translateImpl(casted);
448 if (auto *casted = dyn_cast<llvm::DISubroutineType>(node))
449 return translateImpl(casted);
450 return nullptr;
451 };
452 if (DINodeAttr attr = translateNode(node)) {
453 // If this node was repeated, lookup its recursive ID and assign it to the
454 // base result.
455 if (cacheEntry.wasRepeated()) {
456 DistinctAttr recId = nodeToRecId.lookup(node);
457 auto recType = cast<DIRecursiveTypeAttrInterface>(attr);
458 attr = cast<DINodeAttr>(recType.withRecId(recId));
459 }
460 cacheEntry.resolve(attr);
461 return attr;
462 }
463 cacheEntry.resolve(nullptr);
464 return nullptr;
465}
466
467/// Get the `getRecSelf` constructor for the translated node if it participates
468/// in CyclicReplacerCache cycle breaking (recursive composite types,
469/// subprograms, or compile units).
470static function_ref<DIRecursiveTypeAttrInterface(DistinctAttr)>
471getRecSelfConstructor(llvm::DINode *node) {
472 using CtorType = function_ref<DIRecursiveTypeAttrInterface(DistinctAttr)>;
474 .Case([&](llvm::DICompositeType *) {
475 return CtorType(DICompositeTypeAttr::getRecSelf);
476 })
477 .Case([&](llvm::DISubprogram *) {
478 return CtorType(DISubprogramAttr::getRecSelf);
479 })
480 .Case([&](llvm::DICompileUnit *) {
481 return CtorType(DICompileUnitAttr::getRecSelf);
482 })
483 .Default(CtorType());
484}
485
486std::optional<DINodeAttr> DebugImporter::createRecSelf(llvm::DINode *node) {
487 auto recSelfCtor = getRecSelfConstructor(node);
488 if (!recSelfCtor)
489 return std::nullopt;
490
491 // The original node may have already been assigned a recursive ID from
492 // a different self-reference. Use that if possible.
493 DistinctAttr recId = nodeToRecId.lookup(node);
494 if (!recId) {
495 recId = DistinctAttr::create(UnitAttr::get(context));
496 nodeToRecId[node] = recId;
497 }
498 DIRecursiveTypeAttrInterface recSelf = recSelfCtor(recId);
499 return cast<DINodeAttr>(recSelf);
500}
501
502//===----------------------------------------------------------------------===//
503// Locations
504//===----------------------------------------------------------------------===//
505
506Location DebugImporter::translateLoc(llvm::DILocation *loc) {
507 if (!loc)
508 return UnknownLoc::get(context);
509
510 // Get the file location of the instruction.
511 Location result = FileLineColLoc::get(context, loc->getFilename(),
512 loc->getLine(), loc->getColumn());
513
514 // Add scope information.
515 assert(loc->getScope() && "expected non-null scope");
517 context);
518
519 // Add call site information, if available.
520 if (llvm::DILocation *inlinedAt = loc->getInlinedAt())
521 result = CallSiteLoc::get(result, translateLoc(inlinedAt));
522
523 return result;
524}
525
526DIExpressionAttr DebugImporter::translateExpression(llvm::DIExpression *node) {
527 if (!node)
528 return nullptr;
529
531
532 // Begin processing the operations.
533 for (const llvm::DIExpression::ExprOperand &op : node->expr_ops()) {
534 SmallVector<uint64_t> operands;
535 operands.reserve(op.getNumArgs());
536 for (const auto &i : llvm::seq(op.getNumArgs()))
537 operands.push_back(op.getArg(i));
538 const auto attr = DIExpressionElemAttr::get(context, op.getOp(), operands);
539 ops.push_back(attr);
540 }
541 return DIExpressionAttr::get(context, ops);
542}
543
545 llvm::DIGlobalVariableExpression *node) {
546 return DIGlobalVariableExpressionAttr::get(
547 context, translate(node->getVariable()),
548 translateExpression(node->getExpression()));
549}
550
551StringAttr DebugImporter::getStringAttrOrNull(llvm::MDString *stringNode) {
552 if (!stringNode)
553 return StringAttr();
554 return StringAttr::get(context, stringNode->getString());
555}
556
557DistinctAttr DebugImporter::getOrCreateDistinctID(llvm::DINode *node) {
558 DistinctAttr &id = nodeToDistinctAttr[node];
559 if (!id)
560 id = DistinctAttr::create(UnitAttr::get(context));
561 return id;
562}
static function_ref< DIRecursiveTypeAttrInterface(DistinctAttr)> getRecSelfConstructor(llvm::DINode *node)
Get the getRecSelf constructor for the translated node if it participates in CyclicReplacerCache cycl...
#define add(a, b)
An attribute that associates a referenced attribute with a unique identifier.
static DistinctAttr create(Attribute referencedAttr)
Creates a distinct attribute that associates a referenced attribute with a unique identifier.
static FileLineColLoc get(StringAttr filename, unsigned line, unsigned column)
Definition Location.cpp:157
This class represents a fused location whose metadata is known to be an instance of the given type.
Definition Location.h:149
This class represents the base attribute for all debug info attributes.
Definition LLVMAttrs.h:29
DINodeAttr translate(llvm::DINode *node)
Translates the given LLVM debug metadata to MLIR.
DIExpressionAttr translateExpression(llvm::DIExpression *node)
Translates the LLVM DWARF expression metadata to MLIR.
DIGlobalVariableExpressionAttr translateGlobalVariableExpression(llvm::DIGlobalVariableExpression *node)
Translates the LLVM DWARF global variable expression metadata to MLIR.
Location translateLoc(llvm::DILocation *loc)
Translates the given LLVM debug location to an MLIR location.
Location translateFuncLocation(llvm::Function *func)
Translates the debug information for the given function into a Location.
DebugImporter(ModuleOp mlirModule, bool dropDICompositeTypeElements)
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Definition Location.h:76
The OpAsmOpInterface, see OpAsmInterface.td for more details.
Definition CallGraph.h:227
Include the generated interface declarations.
llvm::TypeSwitch< T, ResultT > TypeSwitch
Definition LLVM.h:139
llvm::function_ref< Fn > function_ref
Definition LLVM.h:147