Skip to content

Commit

Permalink
[clang][OpenMP] Fix missing DI for __kmpc_global_thread_num (#73856)
Browse files Browse the repository at this point in the history
Co-authored-by: Ivan Radanov Ivanov <ivanov2@llnl.gov>
  • Loading branch information
ivanradanov and Ivan Radanov Ivanov committed Nov 30, 2023
1 parent 5a31460 commit 065796b
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
1 change: 1 addition & 0 deletions clang/lib/CodeGen/CGOpenMPRuntime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1441,6 +1441,7 @@ llvm::Value *CGOpenMPRuntime::getThreadID(CodeGenFunction &CGF,
setLocThreadIdInsertPt(CGF);
CGBuilderTy::InsertPointGuard IPG(CGF.Builder);
CGF.Builder.SetInsertPoint(Elem.second.ServiceInsertPt);
auto DL = ApplyDebugLocation::CreateDefaultArtificial(CGF, Loc);
llvm::CallInst *Call = CGF.Builder.CreateCall(
OMPBuilder.getOrCreateRuntimeFunction(CGM.getModule(),
OMPRTL___kmpc_global_thread_num),
Expand Down
17 changes: 17 additions & 0 deletions clang/test/OpenMP/debug-info-kmpc.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// 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
// 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

// Check that we properly attach debug info to the __kmpc_global_thread_num call
// CHECK: call {{.*}} @__kmpc_global_thread_num{{.*}}!dbg

extern int bar();
void foo() {
#pragma omp target teams
{
#pragma omp parallel
{
bar();
}
}
}

0 comments on commit 065796b

Please sign in to comment.