Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[clang][OpenMP] Propagate debug location to OMPIRBuilder reduction codegen #100358

Merged
merged 2 commits into from
Jul 24, 2024

Conversation

jsjodin
Copy link
Contributor

@jsjodin jsjodin commented Jul 24, 2024

This patch propagates the debug location from Clang to the OpenMPIRBuilder.

Fixes #97458

…odegen

This patch propagates the debug location from Clang to the OpenMPIRBuilder.

Fixes llvm#97428
@jsjodin jsjodin requested review from jdoerfert, jhuber6 and TIFitis July 24, 2024 12:23
@llvmbot llvmbot added clang Clang issues not falling into any other category clang:codegen clang:openmp OpenMP related changes to Clang labels Jul 24, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 24, 2024

@llvm/pr-subscribers-clang

@llvm/pr-subscribers-clang-codegen

Author: Jan Leyonberg (jsjodin)

Changes

This patch propagates the debug location from Clang to the OpenMPIRBuilder.

Fixes #97428


Full diff: https://github.com/llvm/llvm-project/pull/100358.diff

1 Files Affected:

  • (modified) clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp (+3-1)
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index fb71b27de9cd0..835662e6cd0a3 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -1652,6 +1652,7 @@ static llvm::Value *castValueToType(CodeGenFunction &CGF, llvm::Value *Val,
 /// Finally, a call is made to '__kmpc_nvptx_parallel_reduce_nowait_v2' to
 /// reduce across workers and compute a globally reduced value.
 ///
+
 void CGOpenMPRuntimeGPU::emitReduction(
     CodeGenFunction &CGF, SourceLocation Loc, ArrayRef<const Expr *> Privates,
     ArrayRef<const Expr *> LHSExprs, ArrayRef<const Expr *> RHSExprs,
@@ -1694,7 +1695,8 @@ void CGOpenMPRuntimeGPU::emitReduction(
                          CGF.AllocaInsertPt->getIterator());
   InsertPointTy CodeGenIP(CGF.Builder.GetInsertBlock(),
                           CGF.Builder.GetInsertPoint());
-  llvm::OpenMPIRBuilder::LocationDescription OmpLoc(CodeGenIP);
+  llvm::OpenMPIRBuilder::LocationDescription OmpLoc(
+      CodeGenIP, CGF.SourceLocToDebugLoc(Loc));
   llvm::SmallVector<llvm::OpenMPIRBuilder::ReductionInfo> ReductionInfos;
 
   CodeGenFunction::OMPPrivateScope Scope(CGF);

@jhuber6
Copy link
Contributor

jhuber6 commented Jul 24, 2024

Is that the right issue?

Copy link
Contributor Author

@jsjodin jsjodin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove added line

clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp Outdated Show resolved Hide resolved
Copy link
Member

@TIFitis TIFitis left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the fix. LGTM.

I've also added some changes in #100364 which should fix some other places where debug info was being incorrectly propagated.

@jhuber6 jhuber6 merged commit 5b15d9c into llvm:main Jul 24, 2024
5 of 7 checks passed
@jsjodin jsjodin changed the title [clang][OpenMP] Propoagate debug location to OMPIRBuilder reduction codegen [clang][OpenMP] Propagate debug location to OMPIRBuilder reduction codegen Jul 24, 2024
llvmbot pushed a commit to llvmbot/llvm-project that referenced this pull request Jul 24, 2024
…odegen (llvm#100358)

This patch propagates the debug location from Clang to the
OpenMPIRBuilder.

Fixes llvm#97458

(cherry picked from commit 5b15d9c)
yuxuanchen1997 pushed a commit that referenced this pull request Jul 25, 2024
…odegen (#100358)

Summary:
This patch propagates the debug location from Clang to the
OpenMPIRBuilder.

Fixes #97458

Test Plan: 

Reviewers: 

Subscribers: 

Tasks: 

Tags: 


Differential Revision: https://phabricator.intern.facebook.com/D60250701
@jsjodin jsjodin deleted the jleyonberg/reductionmigrationbug branch October 1, 2024 14:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
clang:codegen clang:openmp OpenMP related changes to Clang clang Clang issues not falling into any other category
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[OpenMP] New OMPIRBuilder reduction handling does not properly preserve debug metadata.
4 participants