@@ -163,9 +163,10 @@ class ModuleImport {
163163 // / Converts `value` to a float attribute. Asserts if the matching fails.
164164 FloatAttr matchFloatAttr (llvm::Value *value);
165165
166- // / Converts `value` to a local variable attribute. Asserts if the matching
167- // / fails.
168- DILocalVariableAttr matchLocalVariableAttr (llvm::Value *value);
166+ // / Converts `valOrVariable` to a local variable attribute. Asserts if the
167+ // / matching fails.
168+ DILocalVariableAttr matchLocalVariableAttr (
169+ llvm::PointerUnion<llvm::Value *, llvm::DILocalVariable *> valOrVariable);
169170
170171 // / Converts `value` to a label attribute. Asserts if the matching fails.
171172 DILabelAttr matchLabelAttr (llvm::Value *value);
@@ -281,6 +282,9 @@ class ModuleImport {
281282 // / after the function conversion has finished.
282283 void addDebugIntrinsic (llvm::CallInst *intrinsic);
283284
285+ // / Similar to `addDebugIntrinsic`, but for debug records.
286+ void addDebugRecord (llvm::DbgRecord *debugRecord);
287+
284288 // / Converts the LLVM values for an intrinsic to mixed MLIR values and
285289 // / attributes for LLVM_IntrOpBase. Attributes correspond to LLVM immargs. The
286290 // / list `immArgPositions` contains the positions of immargs on the LLVM
@@ -339,9 +343,26 @@ class ModuleImport {
339343 // / Converts all debug intrinsics in `debugIntrinsics`. Assumes that the
340344 // / function containing the intrinsics has been fully converted to MLIR.
341345 LogicalResult processDebugIntrinsics ();
346+ // / Converts all debug records in `debugRecords`. Assumes that the
347+ // / function containing the record has been fully converted to MLIR.
348+ LogicalResult processDebugRecords ();
342349 // / Converts a single debug intrinsic.
343350 LogicalResult processDebugIntrinsic (llvm::DbgVariableIntrinsic *dbgIntr,
344351 DominanceInfo &domInfo);
352+ // / Converts a single debug record.
353+ LogicalResult processDebugRecord (llvm::DbgRecord &debugRecord,
354+ DominanceInfo &domInfo);
355+ // / Process arguments for declare/value operation insertion. `localVarAttr`
356+ // / and `localExprAttr` are the attained attributes after importing the debug
357+ // / variable and expressions. This also sets the builder insertion point to be
358+ // / used by these operations.
359+ std::tuple<DILocalVariableAttr, DIExpressionAttr, Value>
360+ processDebugOpArgumentsAndInsertionPt (
361+ Location loc, bool hasArgList, bool isKillLocation,
362+ llvm::function_ref<FailureOr<Value>()> convertArgOperandToValue,
363+ llvm::Value *address,
364+ llvm::PointerUnion<llvm::Value *, llvm::DILocalVariable *> variable,
365+ llvm::DIExpression *expression, DominanceInfo &domInfo);
345366 // / Converts LLMV IR asm inline call operand's attributes into an array of
346367 // / MLIR attributes to be utilized in `llvm.inline_asm`.
347368 ArrayAttr convertAsmInlineOperandAttrs (const llvm::CallBase &llvmCall);
@@ -485,6 +506,9 @@ class ModuleImport {
485506 // / Function-local list of debug intrinsics that need to be imported after the
486507 // / function conversion has finished.
487508 SetVector<llvm::Instruction *> debugIntrinsics;
509+ // / Function-local list of debug records that need to be imported after the
510+ // / function conversion has finished.
511+ SetVector<llvm::DbgRecord *> debugRecords;
488512 // / Mapping between LLVM alias scope and domain metadata nodes and
489513 // / attributes in the LLVM dialect corresponding to these nodes.
490514 DenseMap<const llvm::MDNode *, Attribute> aliasScopeMapping;
0 commit comments