Skip to content

Commit 065796b

Browse files
authored
[clang][OpenMP] Fix missing DI for __kmpc_global_thread_num (#73856)
Co-authored-by: Ivan Radanov Ivanov <[email protected]>
1 parent 5a31460 commit 065796b

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

clang/lib/CodeGen/CGOpenMPRuntime.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1441,6 +1441,7 @@ llvm::Value *CGOpenMPRuntime::getThreadID(CodeGenFunction &CGF,
14411441
setLocThreadIdInsertPt(CGF);
14421442
CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
14431443
CGF.Builder.SetInsertPoint(Elem.second.ServiceInsertPt);
1444+
auto DL = ApplyDebugLocation::CreateDefaultArtificial(CGF, Loc);
14441445
llvm::CallInst *Call = CGF.Builder.CreateCall(
14451446
OMPBuilder.getOrCreateRuntimeFunction(CGM.getModule(),
14461447
OMPRTL___kmpc_global_thread_num),

clang/test/OpenMP/debug-info-kmpc.cpp

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-ppc-host.bc
2+
// RUN: %clang_cc1 -fopenmp -x c++ -std=c++11 -triple amdgcn-amd-amdhsa -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-target-device "-debug-info-kind=constructor" -fopenmp-host-ir-file-path %t-ppc-host.bc -o - | FileCheck %s
3+
4+
// Check that we properly attach debug info to the __kmpc_global_thread_num call
5+
// CHECK: call {{.*}} @__kmpc_global_thread_num{{.*}}!dbg
6+
7+
extern int bar();
8+
void foo() {
9+
#pragma omp target teams
10+
{
11+
#pragma omp parallel
12+
{
13+
bar();
14+
}
15+
}
16+
}
17+

0 commit comments

Comments
 (0)