Skip to content

Commit c248903

Browse files
authored
[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.
1 parent 7a4af40 commit c248903

File tree

3 files changed

+22
-22
lines changed

3 files changed

+22
-22
lines changed

llvm/include/llvm/Frontend/OpenMP/OMPIRBuilder.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3082,7 +3082,7 @@ class OpenMPIRBuilder {
30823082
TargetBodyGenCallbackTy BodyGenCB,
30833083
TargetGenArgAccessorsCallbackTy ArgAccessorFuncCB,
30843084
CustomMapperCallbackTy CustomMapperCB,
3085-
SmallVector<DependData> Dependencies = {}, bool HasNowait = false);
3085+
const SmallVector<DependData> &Dependencies, bool HasNowait = false);
30863086

30873087
/// Returns __kmpc_for_static_init_* runtime function for the specified
30883088
/// size \a IVSize and sign \a IVSigned. Will create a distribute call

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -7560,18 +7560,18 @@ Error OpenMPIRBuilder::emitOffloadingArraysAndArgs(
75607560
return Error::success();
75617561
}
75627562

7563-
static void
7564-
emitTargetCall(OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder,
7565-
OpenMPIRBuilder::InsertPointTy AllocaIP,
7566-
OpenMPIRBuilder::TargetDataInfo &Info,
7567-
const OpenMPIRBuilder::TargetKernelDefaultAttrs &DefaultAttrs,
7568-
const OpenMPIRBuilder::TargetKernelRuntimeAttrs &RuntimeAttrs,
7569-
Value *IfCond, Function *OutlinedFn, Constant *OutlinedFnID,
7570-
SmallVectorImpl<Value *> &Args,
7571-
OpenMPIRBuilder::GenMapInfoCallbackTy GenMapInfoCB,
7572-
OpenMPIRBuilder::CustomMapperCallbackTy CustomMapperCB,
7573-
SmallVector<llvm::OpenMPIRBuilder::DependData> Dependencies,
7574-
bool HasNoWait) {
7563+
static void emitTargetCall(
7564+
OpenMPIRBuilder &OMPBuilder, IRBuilderBase &Builder,
7565+
OpenMPIRBuilder::InsertPointTy AllocaIP,
7566+
OpenMPIRBuilder::TargetDataInfo &Info,
7567+
const OpenMPIRBuilder::TargetKernelDefaultAttrs &DefaultAttrs,
7568+
const OpenMPIRBuilder::TargetKernelRuntimeAttrs &RuntimeAttrs,
7569+
Value *IfCond, Function *OutlinedFn, Constant *OutlinedFnID,
7570+
SmallVectorImpl<Value *> &Args,
7571+
OpenMPIRBuilder::GenMapInfoCallbackTy GenMapInfoCB,
7572+
OpenMPIRBuilder::CustomMapperCallbackTy CustomMapperCB,
7573+
const SmallVector<llvm::OpenMPIRBuilder::DependData> &Dependencies,
7574+
bool HasNoWait) {
75757575
// Generate a function call to the host fallback implementation of the target
75767576
// region. This is called by the host when no offload entry was generated for
75777577
// the target region and when the offloading call fails at runtime.
@@ -7757,8 +7757,8 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTarget(
77577757
SmallVectorImpl<Value *> &Inputs, GenMapInfoCallbackTy GenMapInfoCB,
77587758
OpenMPIRBuilder::TargetBodyGenCallbackTy CBFunc,
77597759
OpenMPIRBuilder::TargetGenArgAccessorsCallbackTy ArgAccessorFuncCB,
7760-
CustomMapperCallbackTy CustomMapperCB, SmallVector<DependData> Dependencies,
7761-
bool HasNowait) {
7760+
CustomMapperCallbackTy CustomMapperCB,
7761+
const SmallVector<DependData> &Dependencies, bool HasNowait) {
77627762

77637763
if (!updateToLocation(Loc))
77647764
return InsertPointTy();

llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6604,7 +6604,7 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionSPMD) {
66046604
Builder.saveIP(), Info, EntryInfo, DefaultAttrs,
66056605
RuntimeAttrs, /*IfCond=*/nullptr, Inputs,
66066606
GenMapInfoCB, BodyGenCB, SimpleArgAccessorCB,
6607-
CustomMapperCB));
6607+
CustomMapperCB, {}));
66086608
Builder.restoreIP(AfterIP);
66096609

66106610
OMPBuilder.finalize();
@@ -6706,12 +6706,12 @@ TEST_F(OpenMPIRBuilderTest, TargetRegionDeviceSPMD) {
67066706
/*RequiresDevicePointerInfo=*/false,
67076707
/*SeparateBeginEndCalls=*/true);
67086708

6709-
ASSERT_EXPECTED_INIT(
6710-
OpenMPIRBuilder::InsertPointTy, AfterIP,
6711-
OMPBuilder.createTarget(Loc, /*IsOffloadEntry=*/true, EntryIP, EntryIP,
6712-
Info, EntryInfo, DefaultAttrs, RuntimeAttrs,
6713-
/*IfCond=*/nullptr, CapturedArgs, GenMapInfoCB,
6714-
BodyGenCB, SimpleArgAccessorCB, CustomMapperCB));
6709+
ASSERT_EXPECTED_INIT(OpenMPIRBuilder::InsertPointTy, AfterIP,
6710+
OMPBuilder.createTarget(
6711+
Loc, /*IsOffloadEntry=*/true, EntryIP, EntryIP, Info,
6712+
EntryInfo, DefaultAttrs, RuntimeAttrs,
6713+
/*IfCond=*/nullptr, CapturedArgs, GenMapInfoCB,
6714+
BodyGenCB, SimpleArgAccessorCB, CustomMapperCB, {}));
67156715
Builder.restoreIP(AfterIP);
67166716

67176717
Builder.CreateRetVoid();

0 commit comments

Comments
 (0)