Skip to content

Commit dc44fb7

Browse files
committed
Handle review comments.
Separate out the aloca generation in separate function.
1 parent fec5377 commit dc44fb7

File tree

3 files changed

+18
-11
lines changed

3 files changed

+18
-11
lines changed

flang/test/Integration/amdgpu/debug-declare-target-function-var.f90

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,4 @@ function add(a, b) result(ret)
2020
!CHECK: ![[SP]] = {{.*}}!DISubprogram(name: "add"{{.*}})
2121
!CHECK: ![[A]] = !DILocalVariable(name: "a", arg: 1, scope: ![[SP]]{{.*}})
2222
!CHECK: ![[B]] = !DILocalVariable(name: "b", arg: 2, scope: ![[SP]]{{.*}})
23-
!CHECK: ![[RET]] = !DILocalVariable(name: "ret", scope: ![[SP]]{{.*}})
23+
!CHECK: ![[RET]] = !DILocalVariable(name: "ret", scope: ![[SP]]{{.*}})

mlir/lib/Target/LLVMIR/Dialect/OpenMP/OpenMPToLLVMIRTranslation.cpp

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5465,12 +5465,7 @@ static void updateDebugInfoForDeclareTargetVariables(
54655465
}
54665466
}
54675467

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(
54745469
llvm::Function *Fn, LLVM::ModuleTranslation &moduleTranslation) {
54755470
llvm::OpenMPIRBuilder *ompBuilder = moduleTranslation.getOpenMPBuilder();
54765471
llvm::Module &M = ompBuilder->M;
@@ -5528,6 +5523,18 @@ static void updateDebugInfoForDeclareTargetFunctions(
55285523
}
55295524
}
55305525
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;
55315538

55325539
auto AddExpression = [&](auto *DR) {
55335540
llvm::DIExpression *Old = DR->getExpression();
@@ -5579,8 +5586,11 @@ convertDeclareTargetAttr(Operation *op, mlir::omp::DeclareTargetAttr attribute,
55795586
if (declareType == omp::DeclareTargetDeviceType::host) {
55805587
llvmFunc->dropAllReferences();
55815588
llvmFunc->eraseFromParent();
5582-
} else
5589+
} else {
5590+
addAllocasForDeclareTargetFunctionPointerArgs(llvmFunc,
5591+
moduleTranslation);
55835592
updateDebugInfoForDeclareTargetFunctions(llvmFunc, moduleTranslation);
5593+
}
55845594
}
55855595
return success();
55865596
}

mlir/test/Target/LLVMIR/omptarget-decl-target-fn-debug-amdgpu.mlir

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,3 @@ module attributes {llvm.target_triple = "amdgcn-amd-amdhsa", omp.is_target_devic
3131
// CHECK: }
3232
// CHECK: ![[SP]] = {{.*}}!DISubprogram(name: "add"{{.*}})
3333
// CHECK: ![[A]] = !DILocalVariable(name: "a", arg: 1, scope: ![[SP]]{{.*}})
34-
35-
36-

0 commit comments

Comments
 (0)