@@ -93,24 +93,20 @@ void AddDebugFoundationPass::runOnOperation() {
9393 context, llvm::dwarf::getCallingConvention (" DW_CC_normal" ),
9494 {bT, bT});
9595 mlir::LLVM::DIFileAttr funcFileAttr = getFileAttr (funcFilePath);
96- mlir::LLVM::DISubprogramAttr spAttr;
96+
9797 // Only definitions need a distinct identifier and a compilation unit.
98+ mlir::DistinctAttr id;
99+ mlir::LLVM::DICompileUnitAttr compilationUnit;
98100 if (!funcOp.isExternal ()) {
99- auto id = mlir::DistinctAttr::create (mlir::UnitAttr::get (context));
100- spAttr = mlir::LLVM::DISubprogramAttr::get (
101- context, id, cuAttr, fileAttr, funcName, funcName, funcFileAttr,
102- /* line=*/ 1 ,
103- /* scopeline=*/ 1 , mlir::LLVM::DISubprogramFlags::Definition,
104- subTypeAttr);
105- } else {
106- // TODO: Fix the subprogram flags once their modeling has been fixed.
107- spAttr = mlir::LLVM::DISubprogramAttr::get (
108- context, mlir::DistinctAttr (), mlir::LLVM::DICompileUnitAttr (),
109- fileAttr, funcName, funcName, funcFileAttr,
110- /* line=*/ 1 ,
111- /* scopeline=*/ 1 , mlir::LLVM::DISubprogramFlags::Definition,
112- subTypeAttr);
101+ id = mlir::DistinctAttr::create (mlir::UnitAttr::get (context));
102+ compilationUnit = cuAttr;
113103 }
104+ mlir::LLVM::DISubprogramAttr spAttr = mlir::LLVM::DISubprogramAttr::get (
105+ context, id, compilationUnit, fileAttr, funcName, funcName,
106+ funcFileAttr,
107+ /* line=*/ 1 ,
108+ /* scopeline=*/ 1 , mlir::LLVM::DISubprogramFlags::Definition,
109+ subTypeAttr);
114110 funcOp->setLoc (builder.getFusedLoc ({funcOp->getLoc ()}, spAttr));
115111 });
116112}
0 commit comments