@@ -5465,12 +5465,7 @@ static void updateDebugInfoForDeclareTargetVariables(
5465
5465
}
5466
5466
}
5467
5467
5468
- // This function handle any adjustments needed in declare target function to
5469
- // generate valid debug info for AMDGPU. It does 2 main things:
5470
- // 1. Add alloca for arguments passed by reference.
5471
- // 2. Add DIOp based expressions
5472
-
5473
- static void updateDebugInfoForDeclareTargetFunctions (
5468
+ static void addAllocasForDeclareTargetFunctionPointerArgs (
5474
5469
llvm::Function *Fn, LLVM::ModuleTranslation &moduleTranslation) {
5475
5470
llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder ();
5476
5471
llvm::Module &M = ompBuilder->M ;
@@ -5528,6 +5523,18 @@ static void updateDebugInfoForDeclareTargetFunctions(
5528
5523
}
5529
5524
}
5530
5525
builder.restoreIP (curInsert);
5526
+ }
5527
+
5528
+ // This function Add DIOp based expressions to the debug records in the
5529
+ // declare target functions.
5530
+
5531
+ static void updateDebugInfoForDeclareTargetFunctions (
5532
+ llvm::Function *Fn, LLVM::ModuleTranslation &moduleTranslation) {
5533
+ llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder ();
5534
+ llvm::Module &M = ompBuilder->M ;
5535
+
5536
+ if (!llvm::Triple (M.getTargetTriple ()).isAMDGPU ())
5537
+ return ;
5531
5538
5532
5539
auto AddExpression = [&](auto *DR) {
5533
5540
llvm::DIExpression *Old = DR->getExpression ();
@@ -5579,8 +5586,11 @@ convertDeclareTargetAttr(Operation *op, mlir::omp::DeclareTargetAttr attribute,
5579
5586
if (declareType == omp::DeclareTargetDeviceType::host) {
5580
5587
llvmFunc->dropAllReferences ();
5581
5588
llvmFunc->eraseFromParent ();
5582
- } else
5589
+ } else {
5590
+ addAllocasForDeclareTargetFunctionPointerArgs (llvmFunc,
5591
+ moduleTranslation);
5583
5592
updateDebugInfoForDeclareTargetFunctions (llvmFunc, moduleTranslation);
5593
+ }
5584
5594
}
5585
5595
return success ();
5586
5596
}
0 commit comments