Skip to content

Commit dcb1265

Browse files
authored
Revert "[MLIR][LLVM] Make DISubprogramAttr cyclic (#106571)"
This reverts commit d884b77.
1 parent 6f81c87 commit dcb1265

File tree

14 files changed

+176
-263
lines changed

14 files changed

+176
-263
lines changed

flang/lib/Optimizer/Transforms/DebugTypeGenerator.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertBoxedSequenceType(
146146
elements.push_back(subrangeTy);
147147
}
148148
return mlir::LLVM::DICompositeTypeAttr::get(
149-
context, llvm::dwarf::DW_TAG_array_type, /*name=*/nullptr,
150-
/*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, elemTy,
149+
context, llvm::dwarf::DW_TAG_array_type, /*recursive_id=*/{},
150+
/*name=*/nullptr, /*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, elemTy,
151151
mlir::LLVM::DIFlags::Zero, /*sizeInBits=*/0, /*alignInBits=*/0, elements,
152152
dataLocation, /*rank=*/nullptr, allocated, associated);
153153
}
@@ -188,7 +188,7 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertRecordType(
188188
}
189189

190190
return mlir::LLVM::DICompositeTypeAttr::get(
191-
context, llvm::dwarf::DW_TAG_structure_type,
191+
context, llvm::dwarf::DW_TAG_structure_type, /*recursive_id=*/{},
192192
mlir::StringAttr::get(context, result.second.name), fileAttr, line, scope,
193193
/*baseType=*/nullptr, mlir::LLVM::DIFlags::Zero, offset * 8,
194194
/*alignInBits=*/0, elements, /*dataLocation=*/nullptr, /*rank=*/nullptr,
@@ -236,8 +236,8 @@ mlir::LLVM::DITypeAttr DebugTypeGenerator::convertSequenceType(
236236
// have been set to some valid default values.
237237

238238
return mlir::LLVM::DICompositeTypeAttr::get(
239-
context, llvm::dwarf::DW_TAG_array_type, /*name=*/nullptr,
240-
/*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, elemTy,
239+
context, llvm::dwarf::DW_TAG_array_type, /*recursive_id=*/{},
240+
/*name=*/nullptr, /*file=*/nullptr, /*line=*/0, /*scope=*/nullptr, elemTy,
241241
mlir::LLVM::DIFlags::Zero, /*sizeInBits=*/0, /*alignInBits=*/0, elements,
242242
/*dataLocation=*/nullptr, /*rank=*/nullptr, /*allocated=*/nullptr,
243243
/*associated=*/nullptr);

mlir/include/mlir-c/Dialect/LLVM.h

+10-16
Original file line numberDiff line numberDiff line change
@@ -234,13 +234,10 @@ MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIBasicTypeAttrGet(
234234
MlirContext ctx, unsigned int tag, MlirAttribute name, uint64_t sizeInBits,
235235
MlirLLVMTypeEncoding encoding);
236236

237-
/// Creates a self-referencing LLVM DICompositeType attribute.
238-
MlirAttribute mlirLLVMDICompositeTypeAttrGetRecSelf(MlirAttribute recId);
239-
240237
/// Creates a LLVM DICompositeType attribute.
241238
MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDICompositeTypeAttrGet(
242-
MlirContext ctx, MlirAttribute recId, bool isRecSelf, unsigned int tag,
243-
MlirAttribute name, MlirAttribute file, uint32_t line, MlirAttribute scope,
239+
MlirContext ctx, unsigned int tag, MlirAttribute recId, MlirAttribute name,
240+
MlirAttribute file, uint32_t line, MlirAttribute scope,
244241
MlirAttribute baseType, int64_t flags, uint64_t sizeInBits,
245242
uint64_t alignInBits, intptr_t nElements, MlirAttribute const *elements,
246243
MlirAttribute dataLocation, MlirAttribute rank, MlirAttribute allocated,
@@ -314,16 +311,13 @@ MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDILocalVariableAttrGet(
314311
MlirAttribute diFile, unsigned int line, unsigned int arg,
315312
unsigned int alignInBits, MlirAttribute diType, int64_t flags);
316313

317-
/// Creates a self-referencing LLVM DISubprogramAttr attribute.
318-
MlirAttribute mlirLLVMDISubprogramAttrGetRecSelf(MlirAttribute recId);
319-
320314
/// Creates a LLVM DISubprogramAttr attribute.
321315
MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDISubprogramAttrGet(
322-
MlirContext ctx, MlirAttribute recId, bool isRecSelf, MlirAttribute id,
323-
MlirAttribute compileUnit, MlirAttribute scope, MlirAttribute name,
324-
MlirAttribute linkageName, MlirAttribute file, unsigned int line,
325-
unsigned int scopeLine, uint64_t subprogramFlags, MlirAttribute type,
326-
intptr_t nRetainedNodes, MlirAttribute const *retainedNodes);
316+
MlirContext ctx, MlirAttribute id, MlirAttribute compileUnit,
317+
MlirAttribute scope, MlirAttribute name, MlirAttribute linkageName,
318+
MlirAttribute file, unsigned int line, unsigned int scopeLine,
319+
uint64_t subprogramFlags, MlirAttribute type, intptr_t nRetainedNodes,
320+
MlirAttribute const *retainedNodes);
327321

328322
/// Gets the scope from this DISubprogramAttr.
329323
MLIR_CAPI_EXPORTED MlirAttribute
@@ -362,9 +356,9 @@ MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIModuleAttrGet(
362356

363357
/// Creates a LLVM DIImportedEntityAttr attribute.
364358
MLIR_CAPI_EXPORTED MlirAttribute mlirLLVMDIImportedEntityAttrGet(
365-
MlirContext ctx, unsigned int tag, MlirAttribute scope,
366-
MlirAttribute entity, MlirAttribute file, unsigned int line,
367-
MlirAttribute name, intptr_t nElements, MlirAttribute const *elements);
359+
MlirContext ctx, unsigned int tag, MlirAttribute entity, MlirAttribute file,
360+
unsigned int line, MlirAttribute name, intptr_t nElements,
361+
MlirAttribute const *elements);
368362

369363
/// Gets the scope of this DIModuleAttr.
370364
MLIR_CAPI_EXPORTED MlirAttribute

mlir/include/mlir/Dialect/LLVMIR/LLVMAttrDefs.td

+21-47
Original file line numberDiff line numberDiff line change
@@ -271,7 +271,7 @@ def LLVM_DILanguageParameter : LLVM_DIParameter<
271271
>;
272272

273273
def LLVM_DITagParameter : LLVM_DIParameter<
274-
"tag", /*default=*/"0", "Tag", /*errorCase=*/"llvm::dwarf::DW_TAG_invalid"
274+
"tag", /*default=*/"", "Tag", /*errorCase=*/"llvm::dwarf::DW_TAG_invalid"
275275
>;
276276

277277
def LLVM_DIOperationEncodingParameter : LLVM_DIParameter<
@@ -375,17 +375,14 @@ def LLVM_DICompositeTypeAttr : LLVM_Attr<"DICompositeType", "di_composite_type",
375375
[LLVM_DIRecursiveTypeAttrInterface],
376376
"DITypeAttr"> {
377377
let parameters = (ins
378-
// DIRecursiveTypeAttrInterface specific parameters.
379-
OptionalParameter<"DistinctAttr">:$recId,
380-
OptionalParameter<"bool">:$isRecSelf,
381-
// DICompositeType specific parameters.
382378
LLVM_DITagParameter:$tag,
379+
OptionalParameter<"DistinctAttr">:$recId,
383380
OptionalParameter<"StringAttr">:$name,
384381
OptionalParameter<"DIFileAttr">:$file,
385382
OptionalParameter<"uint32_t">:$line,
386383
OptionalParameter<"DIScopeAttr">:$scope,
387384
OptionalParameter<"DITypeAttr">:$baseType,
388-
OptionalParameter<"DIFlags">:$flags,
385+
OptionalParameter<"DIFlags", "DIFlags::Zero">:$flags,
389386
OptionalParameter<"uint64_t">:$sizeInBits,
390387
OptionalParameter<"uint64_t">:$alignInBits,
391388
OptionalArrayRefParameter<"DINodeAttr">:$elements,
@@ -394,26 +391,14 @@ def LLVM_DICompositeTypeAttr : LLVM_Attr<"DICompositeType", "di_composite_type",
394391
OptionalParameter<"DIExpressionAttr">:$allocated,
395392
OptionalParameter<"DIExpressionAttr">:$associated
396393
);
397-
let builders = [
398-
AttrBuilder<(ins
399-
"unsigned":$tag, "StringAttr":$name, "DIFileAttr":$file,
400-
"uint32_t":$line, "DIScopeAttr":$scope, "DITypeAttr":$baseType,
401-
"DIFlags":$flags, "uint64_t":$sizeInBits, "uint64_t":$alignInBits,
402-
"ArrayRef<DINodeAttr>":$elements, "DIExpressionAttr":$dataLocation,
403-
"DIExpressionAttr":$rank, "DIExpressionAttr":$allocated,
404-
"DIExpressionAttr":$associated
405-
), [{
406-
return $_get($_ctxt, /*recId=*/nullptr, /*isRecSelf=*/nullptr,
407-
tag, name, file, line, scope, baseType, flags, sizeInBits,
408-
alignInBits, elements, dataLocation, rank, allocated,
409-
associated);
410-
}]>
411-
];
412394
let assemblyFormat = "`<` struct(params) `>`";
413395
let extraClassDeclaration = [{
414396
/// Requirements of DIRecursiveTypeAttrInterface.
415397
/// @{
416398

399+
/// Get whether this attr describes a recursive self reference.
400+
bool isRecSelf() { return getTag() == 0; }
401+
417402
/// Get a copy of this type attr but with the recursive ID set to `recId`.
418403
DIRecursiveTypeAttrInterface withRecId(DistinctAttr recId);
419404

@@ -569,51 +554,36 @@ def LLVM_DILocalVariableAttr : LLVM_Attr<"DILocalVariable", "di_local_variable",
569554
//===----------------------------------------------------------------------===//
570555

571556
def LLVM_DISubprogramAttr : LLVM_Attr<"DISubprogram", "di_subprogram",
572-
[LLVM_DIRecursiveTypeAttrInterface],
573-
"DIScopeAttr"> {
557+
/*traits=*/[], "DIScopeAttr"> {
574558
let parameters = (ins
575-
// DIRecursiveTypeAttrInterface specific parameters.
576-
OptionalParameter<"DistinctAttr">:$recId,
577-
OptionalParameter<"bool">:$isRecSelf,
578-
// DISubprogramAttr specific parameters.
579559
OptionalParameter<"DistinctAttr">:$id,
580560
OptionalParameter<"DICompileUnitAttr">:$compileUnit,
581-
OptionalParameter<"DIScopeAttr">:$scope,
561+
"DIScopeAttr":$scope,
582562
OptionalParameter<"StringAttr">:$name,
583563
OptionalParameter<"StringAttr">:$linkageName,
584-
OptionalParameter<"DIFileAttr">:$file,
564+
"DIFileAttr":$file,
585565
OptionalParameter<"unsigned">:$line,
586566
OptionalParameter<"unsigned">:$scopeLine,
587567
OptionalParameter<"DISubprogramFlags">:$subprogramFlags,
588568
OptionalParameter<"DISubroutineTypeAttr">:$type,
589569
OptionalArrayRefParameter<"DINodeAttr">:$retainedNodes
590570
);
591571
let builders = [
592-
AttrBuilder<(ins
572+
AttrBuilderWithInferredContext<(ins
593573
"DistinctAttr":$id, "DICompileUnitAttr":$compileUnit,
594-
"DIScopeAttr":$scope, "StringAttr":$name, "StringAttr":$linkageName,
574+
"DIScopeAttr":$scope, "StringRef":$name, "StringRef":$linkageName,
595575
"DIFileAttr":$file, "unsigned":$line, "unsigned":$scopeLine,
596576
"DISubprogramFlags":$subprogramFlags, "DISubroutineTypeAttr":$type,
597577
"ArrayRef<DINodeAttr>":$retainedNodes
598578
), [{
599-
return $_get($_ctxt, /*recId=*/nullptr, /*isRecSelf=*/false, id, compileUnit,
600-
scope, name, linkageName, file, line, scopeLine,
601-
subprogramFlags, type, retainedNodes);
579+
MLIRContext *ctx = file.getContext();
580+
return $_get(ctx, id, compileUnit, scope, StringAttr::get(ctx, name),
581+
StringAttr::get(ctx, linkageName), file, line,
582+
scopeLine, subprogramFlags, type, retainedNodes);
602583
}]>
603584
];
604-
let assemblyFormat = "`<` struct(params) `>`";
605-
let extraClassDeclaration = [{
606-
/// Requirements of DIRecursiveTypeAttrInterface.
607-
/// @{
608-
609-
/// Get a copy of this type attr but with the recursive ID set to `recId`.
610-
DIRecursiveTypeAttrInterface withRecId(DistinctAttr recId);
611585

612-
/// Build a rec-self instance using the provided `recId`.
613-
static DIRecursiveTypeAttrInterface getRecSelf(DistinctAttr recId);
614-
615-
/// @}
616-
}];
586+
let assemblyFormat = "`<` struct(params) `>`";
617587
}
618588

619589
//===----------------------------------------------------------------------===//
@@ -657,9 +627,13 @@ def LLVM_DINamespaceAttr : LLVM_Attr<"DINamespace", "di_namespace",
657627

658628
def LLVM_DIImportedEntityAttr : LLVM_Attr<"DIImportedEntity", "di_imported_entity",
659629
/*traits=*/[], "DINodeAttr"> {
630+
/// TODO: DIImportedEntity has a 'scope' field which represents the scope where
631+
/// this entity is imported. Currently, we are not adding a 'scope' field in
632+
/// DIImportedEntityAttr to avoid cyclic dependency. As DIImportedEntityAttr
633+
/// entries will be contained inside a scope entity (e.g. DISubprogramAttr),
634+
/// the scope can easily be inferred.
660635
let parameters = (ins
661636
LLVM_DITagParameter:$tag,
662-
"DIScopeAttr":$scope,
663637
"DINodeAttr":$entity,
664638
OptionalParameter<"DIFileAttr">:$file,
665639
OptionalParameter<"unsigned">:$line,

mlir/include/mlir/Dialect/LLVMIR/LLVMInterfaces.td

+1-1
Original file line numberDiff line numberDiff line change
@@ -406,7 +406,7 @@ def LLVM_DIRecursiveTypeAttrInterface
406406
let methods = [
407407
InterfaceMethod<[{
408408
Get whether this attr describes a recursive self reference.
409-
}], "bool", "getIsRecSelf", (ins)>,
409+
}], "bool", "isRecSelf", (ins)>,
410410
InterfaceMethod<[{
411411
Get the recursive ID used for matching "rec-decl" with "rec-self".
412412
If this attr instance is not recursive, return a null attribute.

mlir/lib/CAPI/Dialect/LLVM.cpp

+14-25
Original file line numberDiff line numberDiff line change
@@ -159,14 +159,9 @@ MlirAttribute mlirLLVMDIBasicTypeAttrGet(MlirContext ctx, unsigned int tag,
159159
unwrap(ctx), tag, cast<StringAttr>(unwrap(name)), sizeInBits, encoding));
160160
}
161161

162-
MlirAttribute mlirLLVMDICompositeTypeAttrGetRecSelf(MlirAttribute recId) {
163-
return wrap(
164-
DICompositeTypeAttr::getRecSelf(cast<DistinctAttr>(unwrap(recId))));
165-
}
166-
167162
MlirAttribute mlirLLVMDICompositeTypeAttrGet(
168-
MlirContext ctx, MlirAttribute recId, bool isRecSelf, unsigned int tag,
169-
MlirAttribute name, MlirAttribute file, uint32_t line, MlirAttribute scope,
163+
MlirContext ctx, unsigned int tag, MlirAttribute recId, MlirAttribute name,
164+
MlirAttribute file, uint32_t line, MlirAttribute scope,
170165
MlirAttribute baseType, int64_t flags, uint64_t sizeInBits,
171166
uint64_t alignInBits, intptr_t nElements, MlirAttribute const *elements,
172167
MlirAttribute dataLocation, MlirAttribute rank, MlirAttribute allocated,
@@ -175,7 +170,7 @@ MlirAttribute mlirLLVMDICompositeTypeAttrGet(
175170
elementsStorage.reserve(nElements);
176171

177172
return wrap(DICompositeTypeAttr::get(
178-
unwrap(ctx), cast<DistinctAttr>(unwrap(recId)), isRecSelf, tag,
173+
unwrap(ctx), tag, cast<DistinctAttr>(unwrap(recId)),
179174
cast<StringAttr>(unwrap(name)), cast<DIFileAttr>(unwrap(file)), line,
180175
cast<DIScopeAttr>(unwrap(scope)), cast<DITypeAttr>(unwrap(baseType)),
181176
DIFlags(flags), sizeInBits, alignInBits,
@@ -294,21 +289,16 @@ MlirAttribute mlirLLVMDISubroutineTypeAttrGet(MlirContext ctx,
294289
[](Attribute a) { return cast<DITypeAttr>(a); })));
295290
}
296291

297-
MlirAttribute mlirLLVMDISubprogramAttrGetRecSelf(MlirAttribute recId) {
298-
return wrap(DISubprogramAttr::getRecSelf(cast<DistinctAttr>(unwrap(recId))));
299-
}
300-
301292
MlirAttribute mlirLLVMDISubprogramAttrGet(
302-
MlirContext ctx, MlirAttribute recId, bool isRecSelf, MlirAttribute id,
303-
MlirAttribute compileUnit, MlirAttribute scope, MlirAttribute name,
304-
MlirAttribute linkageName, MlirAttribute file, unsigned int line,
305-
unsigned int scopeLine, uint64_t subprogramFlags, MlirAttribute type,
306-
intptr_t nRetainedNodes, MlirAttribute const *retainedNodes) {
293+
MlirContext ctx, MlirAttribute id, MlirAttribute compileUnit,
294+
MlirAttribute scope, MlirAttribute name, MlirAttribute linkageName,
295+
MlirAttribute file, unsigned int line, unsigned int scopeLine,
296+
uint64_t subprogramFlags, MlirAttribute type, intptr_t nRetainedNodes,
297+
MlirAttribute const *retainedNodes) {
307298
SmallVector<Attribute> nodesStorage;
308299
nodesStorage.reserve(nRetainedNodes);
309300
return wrap(DISubprogramAttr::get(
310-
unwrap(ctx), cast<DistinctAttr>(unwrap(recId)), isRecSelf,
311-
cast<DistinctAttr>(unwrap(id)),
301+
unwrap(ctx), cast<DistinctAttr>(unwrap(id)),
312302
cast<DICompileUnitAttr>(unwrap(compileUnit)),
313303
cast<DIScopeAttr>(unwrap(scope)), cast<StringAttr>(unwrap(name)),
314304
cast<StringAttr>(unwrap(linkageName)), cast<DIFileAttr>(unwrap(file)),
@@ -363,15 +353,14 @@ MlirAttribute mlirLLVMDIModuleAttrGetScope(MlirAttribute diModule) {
363353
}
364354

365355
MlirAttribute mlirLLVMDIImportedEntityAttrGet(
366-
MlirContext ctx, unsigned int tag, MlirAttribute scope,
367-
MlirAttribute entity, MlirAttribute file, unsigned int line,
368-
MlirAttribute name, intptr_t nElements, MlirAttribute const *elements) {
356+
MlirContext ctx, unsigned int tag, MlirAttribute entity, MlirAttribute file,
357+
unsigned int line, MlirAttribute name, intptr_t nElements,
358+
MlirAttribute const *elements) {
369359
SmallVector<Attribute> elementsStorage;
370360
elementsStorage.reserve(nElements);
371361
return wrap(DIImportedEntityAttr::get(
372-
unwrap(ctx), tag, cast<DIScopeAttr>(unwrap(scope)),
373-
cast<DINodeAttr>(unwrap(entity)), cast<DIFileAttr>(unwrap(file)), line,
374-
cast<StringAttr>(unwrap(name)),
362+
unwrap(ctx), tag, cast<DINodeAttr>(unwrap(entity)),
363+
cast<DIFileAttr>(unwrap(file)), line, cast<StringAttr>(unwrap(name)),
375364
llvm::map_to_vector(unwrapList(nElements, elements, elementsStorage),
376365
[](Attribute a) { return cast<DINodeAttr>(a); })));
377366
}

mlir/lib/Dialect/LLVMIR/IR/LLVMAttrs.cpp

+6-23
Original file line numberDiff line numberDiff line change
@@ -203,33 +203,16 @@ void printExpressionArg(AsmPrinter &printer, uint64_t opcode,
203203
DIRecursiveTypeAttrInterface
204204
DICompositeTypeAttr::withRecId(DistinctAttr recId) {
205205
return DICompositeTypeAttr::get(
206-
getContext(), recId, getIsRecSelf(), getTag(), getName(), getFile(),
207-
getLine(), getScope(), getBaseType(), getFlags(), getSizeInBits(),
208-
getAlignInBits(), getElements(), getDataLocation(), getRank(),
209-
getAllocated(), getAssociated());
206+
getContext(), getTag(), recId, getName(), getFile(), getLine(),
207+
getScope(), getBaseType(), getFlags(), getSizeInBits(), getAlignInBits(),
208+
getElements(), getDataLocation(), getRank(), getAllocated(),
209+
getAssociated());
210210
}
211211

212212
DIRecursiveTypeAttrInterface
213213
DICompositeTypeAttr::getRecSelf(DistinctAttr recId) {
214-
return DICompositeTypeAttr::get(recId.getContext(), recId, /*isRecSelf=*/true,
215-
0, {}, {}, 0, {}, {}, DIFlags(), 0, 0, {}, {},
216-
{}, {}, {});
217-
}
218-
219-
//===----------------------------------------------------------------------===//
220-
// DISubprogramAttr
221-
//===----------------------------------------------------------------------===//
222-
223-
DIRecursiveTypeAttrInterface DISubprogramAttr::withRecId(DistinctAttr recId) {
224-
return DISubprogramAttr::get(
225-
getContext(), recId, getIsRecSelf(), getId(), getCompileUnit(),
226-
getScope(), getName(), getLinkageName(), getFile(), getLine(),
227-
getScopeLine(), getSubprogramFlags(), getType(), getRetainedNodes());
228-
}
229-
230-
DIRecursiveTypeAttrInterface DISubprogramAttr::getRecSelf(DistinctAttr recId) {
231-
return DISubprogramAttr::get(recId.getContext(), recId, /*isRecSelf=*/true,
232-
{}, {}, {}, {}, {}, 0, 0, {}, {}, {}, {});
214+
return DICompositeTypeAttr::get(recId.getContext(), 0, recId, {}, {}, 0, {},
215+
{}, DIFlags(), 0, 0, {}, {}, {}, {}, {});
233216
}
234217

235218
//===----------------------------------------------------------------------===//

mlir/lib/Dialect/LLVMIR/IR/LLVMDialect.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -3155,9 +3155,9 @@ struct LLVMOpAsmDialectInterface : public OpAsmDialectInterface {
31553155
.Case<AccessGroupAttr, AliasScopeAttr, AliasScopeDomainAttr,
31563156
DIBasicTypeAttr, DICompileUnitAttr, DICompositeTypeAttr,
31573157
DIDerivedTypeAttr, DIFileAttr, DIGlobalVariableAttr,
3158-
DIGlobalVariableExpressionAttr, DIImportedEntityAttr, DILabelAttr,
3159-
DILexicalBlockAttr, DILexicalBlockFileAttr, DILocalVariableAttr,
3160-
DIModuleAttr, DINamespaceAttr, DINullTypeAttr, DIStringTypeAttr,
3158+
DIGlobalVariableExpressionAttr, DILabelAttr, DILexicalBlockAttr,
3159+
DILexicalBlockFileAttr, DILocalVariableAttr, DIModuleAttr,
3160+
DINamespaceAttr, DINullTypeAttr, DIStringTypeAttr,
31613161
DISubprogramAttr, DISubroutineTypeAttr, LoopAnnotationAttr,
31623162
LoopVectorizeAttr, LoopInterleaveAttr, LoopUnrollAttr,
31633163
LoopUnrollAndJamAttr, LoopLICMAttr, LoopDistributeAttr,

mlir/lib/Dialect/LLVMIR/Transforms/DIScopeForLLVMFuncOp.cpp

+5-3
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ static void addScopeToFunction(LLVM::LLVMFuncOp llvmFunc,
6565
auto subroutineTypeAttr =
6666
LLVM::DISubroutineTypeAttr::get(context, llvm::dwarf::DW_CC_normal, {});
6767

68+
StringAttr funcNameAttr = llvmFunc.getNameAttr();
6869
// Only definitions need a distinct identifier and a compilation unit.
6970
DistinctAttr id;
7071
auto subprogramFlags = LLVM::DISubprogramFlags::Optimized;
@@ -74,10 +75,11 @@ static void addScopeToFunction(LLVM::LLVMFuncOp llvmFunc,
7475
} else {
7576
compileUnitAttr = {};
7677
}
77-
auto funcName = StringAttr::get(context, llvmFunc.getName());
7878
auto subprogramAttr = LLVM::DISubprogramAttr::get(
79-
context, id, compileUnitAttr, fileAttr, funcName, funcName, fileAttr,
80-
/*line=*/line, /*scopeline=*/col, subprogramFlags, subroutineTypeAttr,
79+
context, id, compileUnitAttr, fileAttr, funcNameAttr, funcNameAttr,
80+
fileAttr,
81+
/*line=*/line,
82+
/*scopeline=*/col, subprogramFlags, subroutineTypeAttr,
8183
/*retainedNodes=*/{});
8284
llvmFunc->setLoc(FusedLoc::get(context, {loc}, subprogramAttr));
8385
}

0 commit comments

Comments
 (0)