Skip to content

Commit 2351eb2

Browse files
committed
Fix TargetDeInit missing TeamsReductions
1 parent 39f6853 commit 2351eb2

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
lines changed

clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,6 +1673,19 @@ void CGOpenMPRuntimeGPU::emitReduction(
16731673
return;
16741674
}
16751675

1676+
llvm::SmallDenseMap<const ValueDecl *, const FieldDecl *> VarFieldMap;
1677+
llvm::SmallVector<const ValueDecl *, 4> PrivatesReductions(Privates.size());
1678+
int Cnt = 0;
1679+
for (const Expr *DRE : Privates) {
1680+
PrivatesReductions[Cnt] = cast<DeclRefExpr>(DRE)->getDecl();
1681+
++Cnt;
1682+
}
1683+
const RecordDecl *ReductionRec = ::buildRecordForGlobalizedVars(
1684+
CGM.getContext(), PrivatesReductions, std::nullopt, VarFieldMap, 1);
1685+
1686+
if (TeamsReduction)
1687+
TeamsReductions.push_back(ReductionRec);
1688+
16761689
// Source location for the ident struct
16771690
llvm::Value *RTLoc = emitUpdateLocation(CGF, Loc);
16781691

llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2876,7 +2876,7 @@ Function *OpenMPIRBuilder::emitListToGlobalCopyFunction(
28762876
Value *BufferVD =
28772877
Builder.CreateInBoundsGEP(ReductionsBufferTy, BufferArgVal, Idxs);
28782878
Value *GlobVal = Builder.CreateConstInBoundsGEP2_32(
2879-
ReductionsBufferTy, BufferVD, 0, En.index(), "sum");
2879+
ReductionsBufferTy, BufferVD, 0, En.index());
28802880

28812881
switch (RI.EvaluationKind) {
28822882
case EvalKind::Scalar: {
@@ -2987,7 +2987,7 @@ Function *OpenMPIRBuilder::emitListToGlobalReduceFunction(
29872987
Builder.CreateInBoundsGEP(ReductionsBufferTy, BufferVal, Idxs);
29882988
// Global = Buffer.VD[Idx];
29892989
Value *GlobValPtr = Builder.CreateConstInBoundsGEP2_32(
2990-
ReductionsBufferTy, BufferVD, 0, En.index(), "sum");
2990+
ReductionsBufferTy, BufferVD, 0, En.index());
29912991
Builder.CreateStore(GlobValPtr, TargetElementPtrPtr);
29922992
}
29932993

@@ -3066,7 +3066,7 @@ Function *OpenMPIRBuilder::emitGlobalToListCopyFunction(
30663066
Value *BufferVD =
30673067
Builder.CreateInBoundsGEP(ReductionsBufferTy, BufferVal, Idxs);
30683068
Value *GlobValPtr = Builder.CreateConstInBoundsGEP2_32(
3069-
ReductionsBufferTy, BufferVD, 0, En.index(), "sum");
3069+
ReductionsBufferTy, BufferVD, 0, En.index());
30703070

30713071
switch (RI.EvaluationKind) {
30723072
case EvalKind::Scalar: {
@@ -3178,7 +3178,7 @@ Function *OpenMPIRBuilder::emitGlobalToListReduceFunction(
31783178
Value *BufferVD =
31793179
Builder.CreateInBoundsGEP(ReductionsBufferTy, BufferVal, Idxs);
31803180
Value *GlobValPtr = Builder.CreateConstInBoundsGEP2_32(
3181-
ReductionsBufferTy, BufferVD, 0, En.index(), "sum");
3181+
ReductionsBufferTy, BufferVD, 0, En.index());
31823182
Builder.CreateStore(GlobValPtr, TargetElementPtrPtr);
31833183
}
31843184

0 commit comments

Comments
 (0)