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