MLIR  20.0.0git
DebugTranslation.cpp
Go to the documentation of this file.
1 //===- DebugTranslation.cpp - MLIR to LLVM 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 "DebugTranslation.h"
11 #include "llvm/ADT/TypeSwitch.h"
12 #include "llvm/IR/Metadata.h"
13 #include "llvm/IR/Module.h"
14 #include "llvm/Support/FileSystem.h"
15 #include "llvm/Support/Path.h"
16 
17 using namespace mlir;
18 using namespace mlir::LLVM;
19 using namespace mlir::LLVM::detail;
20 
21 /// A utility walker that interrupts if the operation has valid debug
22 /// information.
24  return isa<UnknownLoc>(op->getLoc()) ? WalkResult::advance()
26 }
27 
28 DebugTranslation::DebugTranslation(Operation *module, llvm::Module &llvmModule)
29  : debugEmissionIsEnabled(false), llvmModule(llvmModule),
30  llvmCtx(llvmModule.getContext()) {
31  // If the module has no location information, there is nothing to do.
32  if (!module->walk(interruptIfValidLocation).wasInterrupted())
33  return;
34  debugEmissionIsEnabled = true;
35 
36  // TODO: The version information should be encoded on the LLVM module itself,
37  // not implicitly set here.
38 
39  // Mark this module as having debug information.
40  StringRef debugVersionKey = "Debug Info Version";
41  if (!llvmModule.getModuleFlag(debugVersionKey))
42  llvmModule.addModuleFlag(llvm::Module::Warning, debugVersionKey,
43  llvm::DEBUG_METADATA_VERSION);
44 
45  if (auto targetTripleAttr = module->getDiscardableAttr(
46  LLVM::LLVMDialect::getTargetTripleAttrName())) {
47  auto targetTriple =
48  llvm::Triple(cast<StringAttr>(targetTripleAttr).getValue());
49  if (targetTriple.isKnownWindowsMSVCEnvironment()) {
50  // Dwarf debugging files will be generated by default, unless "CodeView"
51  // is set explicitly. Windows/MSVC should use CodeView instead.
52  llvmModule.addModuleFlag(llvm::Module::Warning, "CodeView", 1);
53  }
54  }
55 }
56 
57 /// Finalize the translation of debug information.
59 
60 /// Translate the debug information for the given function.
61 void DebugTranslation::translate(LLVMFuncOp func, llvm::Function &llvmFunc) {
62  if (!debugEmissionIsEnabled)
63  return;
64 
65  // Look for a sub program attached to the function.
66  auto spLoc =
67  func.getLoc()->findInstanceOf<FusedLocWith<LLVM::DISubprogramAttr>>();
68  if (!spLoc)
69  return;
70  llvmFunc.setSubprogram(translate(spLoc.getMetadata()));
71 }
72 
73 //===----------------------------------------------------------------------===//
74 // Attributes
75 //===----------------------------------------------------------------------===//
76 
77 llvm::DIType *DebugTranslation::translateImpl(DINullTypeAttr attr) {
78  // A DINullTypeAttr at the beginning of the subroutine types list models
79  // a void result type. If it is at the end, it models a variadic function.
80  // Translate the explicit DINullTypeAttr to a nullptr since LLVM IR metadata
81  // does not have an explicit void result type nor a variadic type
82  // representation.
83  return nullptr;
84 }
85 
86 llvm::DIExpression *
87 DebugTranslation::getExpressionAttrOrNull(DIExpressionAttr attr) {
88  if (!attr)
89  return nullptr;
90  return translateExpression(attr);
91 }
92 
93 llvm::MDString *DebugTranslation::getMDStringOrNull(StringAttr stringAttr) {
94  if (!stringAttr || stringAttr.empty())
95  return nullptr;
96  return llvm::MDString::get(llvmCtx, stringAttr);
97 }
98 
99 llvm::DIBasicType *DebugTranslation::translateImpl(DIBasicTypeAttr attr) {
100  return llvm::DIBasicType::get(
101  llvmCtx, attr.getTag(), getMDStringOrNull(attr.getName()),
102  attr.getSizeInBits(),
103  /*AlignInBits=*/0, attr.getEncoding(), llvm::DINode::FlagZero);
104 }
105 
106 llvm::DICompileUnit *DebugTranslation::translateImpl(DICompileUnitAttr attr) {
107  llvm::DIBuilder builder(llvmModule);
108  return builder.createCompileUnit(
109  attr.getSourceLanguage(), translate(attr.getFile()),
110  attr.getProducer() ? attr.getProducer().getValue() : "",
111  attr.getIsOptimized(),
112  /*Flags=*/"", /*RV=*/0, /*SplitName=*/{},
113  static_cast<llvm::DICompileUnit::DebugEmissionKind>(
114  attr.getEmissionKind()),
115  0, true, false,
116  static_cast<llvm::DICompileUnit::DebugNameTableKind>(
117  attr.getNameTableKind()));
118 }
119 
120 /// Returns a new `DINodeT` that is either distinct or not, depending on
121 /// `isDistinct`.
122 template <class DINodeT, class... Ts>
123 static DINodeT *getDistinctOrUnique(bool isDistinct, Ts &&...args) {
124  if (isDistinct)
125  return DINodeT::getDistinct(std::forward<Ts>(args)...);
126  return DINodeT::get(std::forward<Ts>(args)...);
127 }
128 
129 llvm::TempDICompositeType
130 DebugTranslation::translateTemporaryImpl(DICompositeTypeAttr attr) {
131  return llvm::DICompositeType::getTemporary(
132  llvmCtx, attr.getTag(), getMDStringOrNull(attr.getName()), nullptr,
133  attr.getLine(), nullptr, nullptr, attr.getSizeInBits(),
134  attr.getAlignInBits(),
135  /*OffsetInBits=*/0,
136  /*Flags=*/static_cast<llvm::DINode::DIFlags>(attr.getFlags()),
137  /*Elements=*/nullptr, /*RuntimeLang=*/0,
138  /*VTableHolder=*/nullptr);
139 }
140 
141 llvm::DICompositeType *
142 DebugTranslation::translateImpl(DICompositeTypeAttr attr) {
143  // TODO: Use distinct attributes to model this, once they have landed.
144  // Depending on the tag, composite types must be distinct.
145  bool isDistinct = false;
146  switch (attr.getTag()) {
147  case llvm::dwarf::DW_TAG_class_type:
148  case llvm::dwarf::DW_TAG_enumeration_type:
149  case llvm::dwarf::DW_TAG_structure_type:
150  case llvm::dwarf::DW_TAG_union_type:
151  isDistinct = true;
152  }
153 
155  for (DINodeAttr member : attr.getElements())
156  elements.push_back(translate(member));
157 
158  return getDistinctOrUnique<llvm::DICompositeType>(
159  isDistinct, llvmCtx, attr.getTag(), getMDStringOrNull(attr.getName()),
160  translate(attr.getFile()), attr.getLine(), translate(attr.getScope()),
161  translate(attr.getBaseType()), attr.getSizeInBits(),
162  attr.getAlignInBits(),
163  /*OffsetInBits=*/0,
164  /*Flags=*/static_cast<llvm::DINode::DIFlags>(attr.getFlags()),
165  llvm::MDNode::get(llvmCtx, elements),
166  /*RuntimeLang=*/0, /*VTableHolder=*/nullptr,
167  /*TemplateParams=*/nullptr, /*Identifier=*/nullptr,
168  /*Discriminator=*/nullptr,
169  getExpressionAttrOrNull(attr.getDataLocation()),
170  getExpressionAttrOrNull(attr.getAssociated()),
171  getExpressionAttrOrNull(attr.getAllocated()),
172  getExpressionAttrOrNull(attr.getRank()));
173 }
174 
175 llvm::DIDerivedType *DebugTranslation::translateImpl(DIDerivedTypeAttr attr) {
177  llvmCtx, attr.getTag(), getMDStringOrNull(attr.getName()),
178  /*File=*/nullptr, /*Line=*/0,
179  /*Scope=*/nullptr, translate(attr.getBaseType()), attr.getSizeInBits(),
180  attr.getAlignInBits(), attr.getOffsetInBits(),
181  attr.getDwarfAddressSpace(), /*PtrAuthData=*/std::nullopt,
182  /*Flags=*/llvm::DINode::FlagZero, translate(attr.getExtraData()));
183 }
184 
185 llvm::DIStringType *DebugTranslation::translateImpl(DIStringTypeAttr attr) {
187  llvmCtx, attr.getTag(), getMDStringOrNull(attr.getName()),
188  translate(attr.getStringLength()),
189  getExpressionAttrOrNull(attr.getStringLengthExp()),
190  getExpressionAttrOrNull(attr.getStringLocationExp()),
191  attr.getSizeInBits(), attr.getAlignInBits(), attr.getEncoding());
192 }
193 
194 llvm::DIFile *DebugTranslation::translateImpl(DIFileAttr attr) {
195  return llvm::DIFile::get(llvmCtx, getMDStringOrNull(attr.getName()),
196  getMDStringOrNull(attr.getDirectory()));
197 }
198 
199 llvm::DILabel *DebugTranslation::translateImpl(DILabelAttr attr) {
200  return llvm::DILabel::get(llvmCtx, translate(attr.getScope()),
201  getMDStringOrNull(attr.getName()),
202  translate(attr.getFile()), attr.getLine());
203 }
204 
205 llvm::DILexicalBlock *DebugTranslation::translateImpl(DILexicalBlockAttr attr) {
206  return llvm::DILexicalBlock::getDistinct(llvmCtx, translate(attr.getScope()),
207  translate(attr.getFile()),
208  attr.getLine(), attr.getColumn());
209 }
210 
211 llvm::DILexicalBlockFile *
212 DebugTranslation::translateImpl(DILexicalBlockFileAttr attr) {
213  return llvm::DILexicalBlockFile::getDistinct(
214  llvmCtx, translate(attr.getScope()), translate(attr.getFile()),
215  attr.getDiscriminator());
216 }
217 
218 llvm::DILocalScope *DebugTranslation::translateImpl(DILocalScopeAttr attr) {
219  return cast<llvm::DILocalScope>(translate(DINodeAttr(attr)));
220 }
221 
222 llvm::DIVariable *DebugTranslation::translateImpl(DIVariableAttr attr) {
223  return cast<llvm::DIVariable>(translate(DINodeAttr(attr)));
224 }
225 
226 llvm::DILocalVariable *
227 DebugTranslation::translateImpl(DILocalVariableAttr attr) {
229  llvmCtx, translate(attr.getScope()), getMDStringOrNull(attr.getName()),
230  translate(attr.getFile()), attr.getLine(), translate(attr.getType()),
231  attr.getArg(), static_cast<llvm::DINode::DIFlags>(attr.getFlags()),
232  attr.getAlignInBits(),
233  /*Annotations=*/nullptr);
234 }
235 
236 llvm::DIGlobalVariable *
237 DebugTranslation::translateImpl(DIGlobalVariableAttr attr) {
238  return llvm::DIGlobalVariable::getDistinct(
239  llvmCtx, translate(attr.getScope()), getMDStringOrNull(attr.getName()),
240  getMDStringOrNull(attr.getLinkageName()), translate(attr.getFile()),
241  attr.getLine(), translate(attr.getType()), attr.getIsLocalToUnit(),
242  attr.getIsDefined(), nullptr, nullptr, attr.getAlignInBits(), nullptr);
243 }
244 
245 llvm::DIType *
246 DebugTranslation::translateRecursive(DIRecursiveTypeAttrInterface attr) {
247  DistinctAttr recursiveId = attr.getRecId();
248  if (auto *iter = recursiveTypeMap.find(recursiveId);
249  iter != recursiveTypeMap.end()) {
250  return iter->second;
251  } else {
252  assert(!attr.isRecSelf() && "unbound DI recursive self type");
253  }
254 
255  auto setRecursivePlaceholder = [&](llvm::DIType *placeholder) {
256  recursiveTypeMap.try_emplace(recursiveId, placeholder);
257  };
258 
259  llvm::DIType *result =
261  .Case<DICompositeTypeAttr>([&](auto attr) {
262  auto temporary = translateTemporaryImpl(attr);
263  setRecursivePlaceholder(temporary.get());
264  // Must call `translateImpl` directly instead of `translate` to
265  // avoid handling the recursive interface again.
266  auto *concrete = translateImpl(attr);
267  temporary->replaceAllUsesWith(concrete);
268  return concrete;
269  });
270 
271  assert(recursiveTypeMap.back().first == recursiveId &&
272  "internal inconsistency: unexpected recursive translation stack");
273  recursiveTypeMap.pop_back();
274 
275  return result;
276 }
277 
278 llvm::DIScope *DebugTranslation::translateImpl(DIScopeAttr attr) {
279  return cast<llvm::DIScope>(translate(DINodeAttr(attr)));
280 }
281 
282 llvm::DISubprogram *DebugTranslation::translateImpl(DISubprogramAttr attr) {
283  if (auto iter = distinctAttrToNode.find(attr.getId());
284  iter != distinctAttrToNode.end())
285  return cast<llvm::DISubprogram>(iter->second);
286 
287  llvm::DIScope *scope = translate(attr.getScope());
288  llvm::DIFile *file = translate(attr.getFile());
289  llvm::DIType *type = translate(attr.getType());
290  llvm::DICompileUnit *compileUnit = translate(attr.getCompileUnit());
291 
292  // Check again after recursive calls in case this distinct node recurses back
293  // to itself.
294  if (auto iter = distinctAttrToNode.find(attr.getId());
295  iter != distinctAttrToNode.end())
296  return cast<llvm::DISubprogram>(iter->second);
297 
298  bool isDefinition = static_cast<bool>(attr.getSubprogramFlags() &
299  LLVM::DISubprogramFlags::Definition);
300  llvm::DISubprogram *node = getDistinctOrUnique<llvm::DISubprogram>(
301  isDefinition, llvmCtx, scope, getMDStringOrNull(attr.getName()),
302  getMDStringOrNull(attr.getLinkageName()), file, attr.getLine(), type,
303  attr.getScopeLine(),
304  /*ContainingType=*/nullptr, /*VirtualIndex=*/0,
305  /*ThisAdjustment=*/0, llvm::DINode::FlagZero,
306  static_cast<llvm::DISubprogram::DISPFlags>(attr.getSubprogramFlags()),
307  compileUnit);
308 
309  if (attr.getId())
310  distinctAttrToNode.try_emplace(attr.getId(), node);
311  return node;
312 }
313 
314 llvm::DIModule *DebugTranslation::translateImpl(DIModuleAttr attr) {
315  return llvm::DIModule::get(
316  llvmCtx, translate(attr.getFile()), translate(attr.getScope()),
317  getMDStringOrNull(attr.getName()),
318  getMDStringOrNull(attr.getConfigMacros()),
319  getMDStringOrNull(attr.getIncludePath()),
320  getMDStringOrNull(attr.getApinotes()), attr.getLine(), attr.getIsDecl());
321 }
322 
323 llvm::DINamespace *DebugTranslation::translateImpl(DINamespaceAttr attr) {
324  return llvm::DINamespace::get(llvmCtx, translate(attr.getScope()),
325  getMDStringOrNull(attr.getName()),
326  attr.getExportSymbols());
327 }
328 
329 llvm::DISubrange *DebugTranslation::translateImpl(DISubrangeAttr attr) {
330  auto getMetadataOrNull = [&](Attribute attr) -> llvm::Metadata * {
331  if (!attr)
332  return nullptr;
333 
334  llvm::Metadata *metadata =
336  .Case([&](IntegerAttr intAttr) {
337  return llvm::ConstantAsMetadata::get(llvm::ConstantInt::getSigned(
338  llvm::Type::getInt64Ty(llvmCtx), intAttr.getInt()));
339  })
340  .Case([&](LLVM::DIExpressionAttr expr) {
341  return translateExpression(expr);
342  })
343  .Case([&](LLVM::DILocalVariableAttr local) {
344  return translate(local);
345  })
346  .Case<>([&](LLVM::DIGlobalVariableAttr global) {
347  return translate(global);
348  })
349  .Default([&](Attribute attr) { return nullptr; });
350  return metadata;
351  };
352  return llvm::DISubrange::get(llvmCtx, getMetadataOrNull(attr.getCount()),
353  getMetadataOrNull(attr.getLowerBound()),
354  getMetadataOrNull(attr.getUpperBound()),
355  getMetadataOrNull(attr.getStride()));
356 }
357 
358 llvm::DISubroutineType *
359 DebugTranslation::translateImpl(DISubroutineTypeAttr attr) {
360  // Concatenate the result and argument types into a single array.
362  for (DITypeAttr type : attr.getTypes())
363  types.push_back(translate(type));
365  llvmCtx, llvm::DINode::FlagZero, attr.getCallingConvention(),
366  llvm::DITypeRefArray(llvm::MDNode::get(llvmCtx, types)));
367 }
368 
369 llvm::DIType *DebugTranslation::translateImpl(DITypeAttr attr) {
370  return cast<llvm::DIType>(translate(DINodeAttr(attr)));
371 }
372 
374  if (!attr)
375  return nullptr;
376  // Check for a cached instance.
377  if (llvm::DINode *node = attrToNode.lookup(attr))
378  return node;
379 
380  llvm::DINode *node = nullptr;
381  // Recursive types go through a dedicated handler. All other types are
382  // dispatched directly to their specific handlers.
383  if (auto recTypeAttr = dyn_cast<DIRecursiveTypeAttrInterface>(attr))
384  if (recTypeAttr.getRecId())
385  node = translateRecursive(recTypeAttr);
386 
387  if (!node)
389  .Case<DIBasicTypeAttr, DICompileUnitAttr, DICompositeTypeAttr,
390  DIDerivedTypeAttr, DIFileAttr, DIGlobalVariableAttr,
391  DILabelAttr, DILexicalBlockAttr, DILexicalBlockFileAttr,
392  DILocalVariableAttr, DIModuleAttr, DINamespaceAttr,
393  DINullTypeAttr, DIStringTypeAttr, DISubprogramAttr,
394  DISubrangeAttr, DISubroutineTypeAttr>(
395  [&](auto attr) { return translateImpl(attr); });
396 
397  if (node && !node->isTemporary())
398  attrToNode.insert({attr, node});
399  return node;
400 }
401 
402 //===----------------------------------------------------------------------===//
403 // Locations
404 //===----------------------------------------------------------------------===//
405 
406 /// Translate the given location to an llvm debug location.
407 llvm::DILocation *DebugTranslation::translateLoc(Location loc,
408  llvm::DILocalScope *scope) {
409  if (!debugEmissionIsEnabled)
410  return nullptr;
411  return translateLoc(loc, scope, /*inlinedAt=*/nullptr);
412 }
413 
414 llvm::DIExpression *
415 DebugTranslation::translateExpression(LLVM::DIExpressionAttr attr) {
417  if (attr) {
418  // Append operations their operands to the list.
419  for (const DIExpressionElemAttr &op : attr.getOperations()) {
420  ops.push_back(op.getOpcode());
421  append_range(ops, op.getArguments());
422  }
423  }
424  return llvm::DIExpression::get(llvmCtx, ops);
425 }
426 
427 llvm::DIGlobalVariableExpression *
428 DebugTranslation::translateGlobalVariableExpression(
429  LLVM::DIGlobalVariableExpressionAttr attr) {
431  llvmCtx, translate(attr.getVar()), translateExpression(attr.getExpr()));
432 }
433 
434 /// Translate the given location to an llvm DebugLoc.
435 llvm::DILocation *DebugTranslation::translateLoc(Location loc,
436  llvm::DILocalScope *scope,
437  llvm::DILocation *inlinedAt) {
438  // LLVM doesn't have a representation for unknown.
439  if (isa<UnknownLoc>(loc))
440  return nullptr;
441 
442  // Check for a cached instance.
443  auto existingIt = locationToLoc.find(std::make_tuple(loc, scope, inlinedAt));
444  if (existingIt != locationToLoc.end())
445  return existingIt->second;
446 
447  llvm::DILocation *llvmLoc = nullptr;
448  if (auto callLoc = dyn_cast<CallSiteLoc>(loc)) {
449  // For callsites, the caller is fed as the inlinedAt for the callee.
450  auto *callerLoc = translateLoc(callLoc.getCaller(), scope, inlinedAt);
451  // If the caller scope is not translatable, the overall callsite cannot be
452  // represented in LLVM (the callee scope may not match the parent function).
453  if (!callerLoc) {
454  // If there is an inlinedAt scope (an outer caller), skip to that
455  // directly. Otherwise, cannot translate.
456  if (!inlinedAt)
457  return nullptr;
458  callerLoc = inlinedAt;
459  }
460  llvmLoc = translateLoc(callLoc.getCallee(), nullptr, callerLoc);
461  // Fallback: Ignore callee if it has no debug scope.
462  if (!llvmLoc)
463  llvmLoc = callerLoc;
464 
465  } else if (auto fileLoc = dyn_cast<FileLineColLoc>(loc)) {
466  // A scope of a DILocation cannot be null.
467  if (!scope)
468  return nullptr;
469  llvmLoc =
470  llvm::DILocation::get(llvmCtx, fileLoc.getLine(), fileLoc.getColumn(),
471  scope, const_cast<llvm::DILocation *>(inlinedAt));
472 
473  } else if (auto fusedLoc = dyn_cast<FusedLoc>(loc)) {
474  ArrayRef<Location> locations = fusedLoc.getLocations();
475 
476  // Check for a scope encoded with the location.
477  if (auto scopedAttr =
478  dyn_cast_or_null<LLVM::DILocalScopeAttr>(fusedLoc.getMetadata()))
479  scope = translate(scopedAttr);
480 
481  // For fused locations, merge each of the nodes.
482  llvmLoc = translateLoc(locations.front(), scope, inlinedAt);
483  for (Location locIt : locations.drop_front()) {
484  llvmLoc = llvm::DILocation::getMergedLocation(
485  llvmLoc, translateLoc(locIt, scope, inlinedAt));
486  }
487 
488  } else if (auto nameLoc = dyn_cast<NameLoc>(loc)) {
489  llvmLoc = translateLoc(nameLoc.getChildLoc(), scope, inlinedAt);
490 
491  } else if (auto opaqueLoc = dyn_cast<OpaqueLoc>(loc)) {
492  llvmLoc = translateLoc(opaqueLoc.getFallbackLocation(), scope, inlinedAt);
493  } else {
494  llvm_unreachable("unknown location kind");
495  }
496 
497  locationToLoc.try_emplace(std::make_tuple(loc, scope, inlinedAt), llvmLoc);
498  return llvmLoc;
499 }
500 
501 /// Create an llvm debug file for the given file path.
502 llvm::DIFile *DebugTranslation::translateFile(StringRef fileName) {
503  auto *&file = fileMap[fileName];
504  if (file)
505  return file;
506 
507  // Make sure the current working directory is up-to-date.
508  if (currentWorkingDir.empty())
509  llvm::sys::fs::current_path(currentWorkingDir);
510 
511  StringRef directory = currentWorkingDir;
512  SmallString<128> dirBuf;
513  SmallString<128> fileBuf;
514  if (llvm::sys::path::is_absolute(fileName)) {
515  // Strip the common prefix (if it is more than just "/") from current
516  // directory and FileName for a more space-efficient encoding.
517  auto fileIt = llvm::sys::path::begin(fileName);
518  auto fileE = llvm::sys::path::end(fileName);
519  auto curDirIt = llvm::sys::path::begin(directory);
520  auto curDirE = llvm::sys::path::end(directory);
521  for (; curDirIt != curDirE && *curDirIt == *fileIt; ++curDirIt, ++fileIt)
522  llvm::sys::path::append(dirBuf, *curDirIt);
523  if (std::distance(llvm::sys::path::begin(directory), curDirIt) == 1) {
524  // Don't strip the common prefix if it is only the root "/" since that
525  // would make LLVM diagnostic locations confusing.
526  directory = StringRef();
527  } else {
528  for (; fileIt != fileE; ++fileIt)
529  llvm::sys::path::append(fileBuf, *fileIt);
530  directory = dirBuf;
531  fileName = fileBuf;
532  }
533  }
534  return (file = llvm::DIFile::get(llvmCtx, fileName, directory));
535 }
static DINodeT * getDistinctOrUnique(bool isDistinct, Ts &&...args)
Returns a new DINodeT that is either distinct or not, depending on isDistinct.
static WalkResult interruptIfValidLocation(Operation *op)
A utility walker that interrupts if the operation has valid debug information.
static MLIRContext * getContext(OpFoldResult val)
Attributes are known-constant values of operations.
Definition: Attributes.h:25
An attribute that associates a referenced attribute with a unique identifier.
This class represents a fused location whose metadata is known to be an instance of the given type.
Definition: Location.h:148
This class represents a LLVM attribute that describes a local debug info scope.
Definition: LLVMAttrs.h:46
This class represents the base attribute for all debug info attributes.
Definition: LLVMAttrs.h:27
This class represents a LLVM attribute that describes a debug info scope.
Definition: LLVMAttrs.h:36
This class represents a LLVM attribute that describes a debug info type.
Definition: LLVMAttrs.h:55
This class represents a LLVM attribute that describes a debug info variable.
Definition: LLVMAttrs.h:64
void finalize()
Finalize the translation of debug information.
void translate(LLVMFuncOp func, llvm::Function &llvmFunc)
Translate the debug information for the given function.
llvm::DIExpression * translateExpression(LLVM::DIExpressionAttr attr)
Translates the given DWARF expression metadata to to LLVM.
DebugTranslation(Operation *module, llvm::Module &llvmModule)
This class defines the main interface for locations in MLIR and acts as a non-nullable wrapper around...
Definition: Location.h:63
Operation is the basic unit of execution within MLIR.
Definition: Operation.h:88
Attribute getDiscardableAttr(StringRef name)
Access a discardable attribute by name, returns an null Attribute if the discardable attribute does n...
Definition: Operation.h:448
std::enable_if_t< llvm::function_traits< std::decay_t< FnT > >::num_args==1, RetT > walk(FnT &&callback)
Walk the operation by calling the callback for each nested operation (including this one),...
Definition: Operation.h:793
Location getLoc()
The source location the operation was defined or derived from.
Definition: Operation.h:223
A utility result that is used to signal how to proceed with an ongoing walk:
Definition: Visitors.h:33
static WalkResult advance()
Definition: Visitors.h:51
static WalkResult interrupt()
Definition: Visitors.h:50
Include the generated interface declarations.
auto get(MLIRContext *context, Ts &&...params)
Helper method that injects context only if needed, this helps unify some of the attribute constructio...