[llvm] c248903 - [OpenMP][NFC] Use pass by const ref for Dependencies (#139592)
via llvm-commits
llvm-commits at lists.llvm.org
Tue May 13 09:09:40 PDT 2025
Author: Shafik Yaghmour
Date: 2025-05-13T09:09:37-07:00
New Revision: c24890305378979a66ea6d35bee754c03e61178f
URL: https://github.com/llvm/llvm-project/commit/c24890305378979a66ea6d35bee754c03e61178f
DIFF: https://github.com/llvm/llvm-project/commit/c24890305378979a66ea6d35bee754c03e61178f.diff
LOG: [OpenMP][NFC] Use pass by const ref for Dependencies (#139592)
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 only used in two lines in a test and changing those two locations
was easy.
Added:
Modified:
llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
Removed:
################################################################################
diff --git a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
index ffc0fd0a0bdac..f74a15a52f2d3 100644
--- a/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
+++ b/llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h
@@ -3082,7 +3082,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 a1268ca76b2d5..000b0c3766a46 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -7560,18 +7560,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.
@@ -7757,8 +7757,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();
diff --git a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
index 1a1bb031afa7c..b98dc0c9ae1a1 100644
--- a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -6604,7 +6604,7 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionSPMD) {
Builder.saveIP(), Info, EntryInfo, DefaultAttrs,
RuntimeAttrs, /*IfCond=*/nullptr, Inputs,
GenMapInfoCB, BodyGenCB, SimpleArgAccessorCB,
- CustomMapperCB));
+ CustomMapperCB, {}));
Builder.restoreIP(AfterIP);
OMPBuilder.finalize();
@@ -6706,12 +6706,12 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDeviceSPMD) {
/*RequiresDevicePointerInfo=*/false,
/*SeparateBeginEndCalls=*/true);
- ASSERT_EXPECTED_INIT(
- OpenMPIRBuilder::InsertPointTy, AfterIP,
- OMPBuilder.createTarget(Loc, /*IsOffloadEntry=*/true, EntryIP, EntryIP,
- Info, EntryInfo, DefaultAttrs, RuntimeAttrs,
- /*IfCond=*/nullptr, CapturedArgs, GenMapInfoCB,
- BodyGenCB, SimpleArgAccessorCB, CustomMapperCB));
+ ASSERT_EXPECTED_INIT(OpenMPIRBuilder::InsertPointTy, AfterIP,
+ OMPBuilder.createTarget(
+ Loc, /*IsOffloadEntry=*/true, EntryIP, EntryIP, Info,
+ EntryInfo, DefaultAttrs, RuntimeAttrs,
+ /*IfCond=*/nullptr, CapturedArgs, GenMapInfoCB,
+ BodyGenCB, SimpleArgAccessorCB, CustomMapperCB, {}));
Builder.restoreIP(AfterIP);
Builder.CreateRetVoid();
More information about the llvm-commits
mailing list