[llvm] [OpenMP][NFC] Use pass by const ref for Dependencies (PR #139592)
via llvm-commits
llvm-commits at lists.llvm.org
Mon May 12 10:47:50 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-openmp
Author: Shafik Yaghmour (shafik)
<details>
<summary>Changes</summary>
Static analysis flagged the passing of Dependencies to emitTargetCall as a
place we could use std::move to avoid copying. A closer look indicated we could
instead turn the parameter into a const & and not have a default value since it
was not utilized in tree at all.
---
Full diff: https://github.com/llvm/llvm-project/pull/139592.diff
2 Files Affected:
- (modified) llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h (+1-1)
- (modified) llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp (+14-14)
``````````diff
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
index 10d69e561a987..ec010c19cb1a6 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -3072,7 +3072,7 @@ class OpenMPIRBuilder {
TargetBodyGenCallbackTy BodyGenCB,
TargetGenArgAccessorsCallbackTy ArgAccessorFuncCB,
CustomMapperCallbackTy CustomMapperCB,
- SmallVector<DependData> Dependencies = {}, bool HasNowait = false);
+ const SmallVector<DependData> &Dependencies, bool HasNowait = false);
/// Returns __kmpc_for_static_init_* runtime function for the specified
/// size \a IVSize and sign \a IVSigned. Will create a distribute call
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index be05f01c94603..4109c3d014044 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -7528,18 +7528,18 @@ Error OpenMPIRBuilder::emitOffloadingArraysAndArgs(
return Error::success();
}
-static void
-emitTargetCall(OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder,
- OpenMPIRBuilder::InsertPointTy AllocaIP,
- OpenMPIRBuilder::TargetDataInfo &Info,
- const OpenMPIRBuilder::TargetKernelDefaultAttrs &DefaultAttrs,
- const OpenMPIRBuilder::TargetKernelRuntimeAttrs &RuntimeAttrs,
- Value *IfCond, Function *OutlinedFn, Constant *OutlinedFnID,
- SmallVectorImpl<Value *> &Args,
- OpenMPIRBuilder::GenMapInfoCallbackTy GenMapInfoCB,
- OpenMPIRBuilder::CustomMapperCallbackTy CustomMapperCB,
- SmallVector<llvm::OpenMPIRBuilder::DependData> Dependencies,
- bool HasNoWait) {
+static void emitTargetCall(
+ OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder,
+ OpenMPIRBuilder::InsertPointTy AllocaIP,
+ OpenMPIRBuilder::TargetDataInfo &Info,
+ const OpenMPIRBuilder::TargetKernelDefaultAttrs &DefaultAttrs,
+ const OpenMPIRBuilder::TargetKernelRuntimeAttrs &RuntimeAttrs,
+ Value *IfCond, Function *OutlinedFn, Constant *OutlinedFnID,
+ SmallVectorImpl<Value *> &Args,
+ OpenMPIRBuilder::GenMapInfoCallbackTy GenMapInfoCB,
+ OpenMPIRBuilder::CustomMapperCallbackTy CustomMapperCB,
+ const SmallVector<llvm::OpenMPIRBuilder::DependData> &Dependencies,
+ bool HasNoWait) {
// Generate a function call to the host fallback implementation of the target
// region. This is called by the host when no offload entry was generated for
// the target region and when the offloading call fails at runtime.
@@ -7725,8 +7725,8 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTarget(
SmallVectorImpl<Value *> &Inputs, GenMapInfoCallbackTy GenMapInfoCB,
OpenMPIRBuilder::TargetBodyGenCallbackTy CBFunc,
OpenMPIRBuilder::TargetGenArgAccessorsCallbackTy ArgAccessorFuncCB,
- CustomMapperCallbackTy CustomMapperCB, SmallVector<DependData> Dependencies,
- bool HasNowait) {
+ CustomMapperCallbackTy CustomMapperCB,
+ const SmallVector<DependData> &Dependencies, bool HasNowait) {
if (!updateToLocation(Loc))
return InsertPointTy();
``````````
</details>
https://github.com/llvm/llvm-project/pull/139592
More information about the llvm-commits
mailing list