@@ -1809,6 +1809,7 @@ void CodeGenFunction::EmitOMPParallelDirective(const OMPParallelDirective &S) {
18091809 // thus calls destructors etc.
18101810 auto FiniCB = [this ](InsertPointTy IP) {
18111811 OMPBuilderCBHelpers::FinalizeOMPRegion (*this , IP);
1812+ return llvm::Error::success ();
18121813 };
18131814
18141815 // Privatization callback that performs appropriate action for
@@ -1831,15 +1832,18 @@ void CodeGenFunction::EmitOMPParallelDirective(const OMPParallelDirective &S) {
18311832 InsertPointTy CodeGenIP) {
18321833 OMPBuilderCBHelpers::EmitOMPOutlinedRegionBody (
18331834 *this , ParallelRegionBodyStmt, AllocaIP, CodeGenIP, " parallel" );
1835+ return llvm::Error::success ();
18341836 };
18351837
18361838 CGCapturedStmtInfo CGSI (*CS, CR_OpenMP);
18371839 CodeGenFunction::CGCapturedStmtRAII CapInfoRAII (*this , &CGSI);
18381840 llvm::OpenMPIRBuilder::InsertPointTy AllocaIP (
18391841 AllocaInsertPt->getParent (), AllocaInsertPt->getIterator ());
1840- Builder. restoreIP (
1842+ llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
18411843 OMPBuilder.createParallel (Builder, AllocaIP, BodyGenCB, PrivCB, FiniCB,
1842- IfCond, NumThreads, ProcBind, S.hasCancel ()));
1844+ IfCond, NumThreads, ProcBind, S.hasCancel ());
1845+ assert (AfterIP && " unexpected error creating parallel" );
1846+ Builder.restoreIP (*AfterIP);
18431847 return ;
18441848 }
18451849
@@ -2128,9 +2132,13 @@ void CodeGenFunction::EmitOMPCanonicalLoop(const OMPCanonicalLoop *S) {
21282132
21292133 RunCleanupsScope BodyScope (*this );
21302134 EmitStmt (BodyStmt);
2135+ return llvm::Error::success ();
21312136 };
2132- llvm::CanonicalLoopInfo *CL =
2137+
2138+ llvm::Expected<llvm::CanonicalLoopInfo *> Result =
21332139 OMPBuilder.createCanonicalLoop (Builder, BodyGen, DistVal);
2140+ assert (Result && " unexpected error creating canonical loop" );
2141+ llvm::CanonicalLoopInfo *CL = *Result;
21342142
21352143 // Finish up the loop.
21362144 Builder.restoreIP (CL->getAfterIP ());
@@ -4016,11 +4024,13 @@ static void emitOMPForDirective(const OMPLoopDirective &S, CodeGenFunction &CGF,
40164024 CGM.getOpenMPRuntime ().getOMPBuilder ();
40174025 llvm::OpenMPIRBuilder::InsertPointTy AllocaIP (
40184026 CGF.AllocaInsertPt ->getParent (), CGF.AllocaInsertPt ->getIterator ());
4019- OMPBuilder.applyWorkshareLoop (
4020- CGF.Builder .getCurrentDebugLocation (), CLI, AllocaIP, NeedsBarrier,
4021- SchedKind, ChunkSize, /* HasSimdModifier=*/ false ,
4022- /* HasMonotonicModifier=*/ false , /* HasNonmonotonicModifier=*/ false ,
4023- /* HasOrderedClause=*/ false );
4027+ llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
4028+ OMPBuilder.applyWorkshareLoop (
4029+ CGF.Builder .getCurrentDebugLocation (), CLI, AllocaIP,
4030+ NeedsBarrier, SchedKind, ChunkSize, /* HasSimdModifier=*/ false ,
4031+ /* HasMonotonicModifier=*/ false , /* HasNonmonotonicModifier=*/ false ,
4032+ /* HasOrderedClause=*/ false );
4033+ assert (AfterIP && " unexpected error creating workshare loop" );
40244034 return ;
40254035 }
40264036
@@ -4257,6 +4267,7 @@ void CodeGenFunction::EmitOMPSectionsDirective(const OMPSectionsDirective &S) {
42574267
42584268 auto FiniCB = [this ](InsertPointTy IP) {
42594269 OMPBuilderCBHelpers::FinalizeOMPRegion (*this , IP);
4270+ return llvm::Error::success ();
42604271 };
42614272
42624273 const CapturedStmt *ICS = S.getInnermostCapturedStmt ();
@@ -4269,6 +4280,7 @@ void CodeGenFunction::EmitOMPSectionsDirective(const OMPSectionsDirective &S) {
42694280 InsertPointTy CodeGenIP) {
42704281 OMPBuilderCBHelpers::EmitOMPInlinedRegionBody (
42714282 *this , SubStmt, AllocaIP, CodeGenIP, " section" );
4283+ return llvm::Error::success ();
42724284 };
42734285 SectionCBVector.push_back (SectionCB);
42744286 }
@@ -4277,6 +4289,7 @@ void CodeGenFunction::EmitOMPSectionsDirective(const OMPSectionsDirective &S) {
42774289 InsertPointTy CodeGenIP) {
42784290 OMPBuilderCBHelpers::EmitOMPInlinedRegionBody (
42794291 *this , CapturedStmt, AllocaIP, CodeGenIP, " section" );
4292+ return llvm::Error::success ();
42804293 };
42814294 SectionCBVector.push_back (SectionCB);
42824295 }
@@ -4298,9 +4311,12 @@ void CodeGenFunction::EmitOMPSectionsDirective(const OMPSectionsDirective &S) {
42984311 CodeGenFunction::CGCapturedStmtRAII CapInfoRAII (*this , &CGSI);
42994312 llvm::OpenMPIRBuilder::InsertPointTy AllocaIP (
43004313 AllocaInsertPt->getParent (), AllocaInsertPt->getIterator ());
4301- Builder.restoreIP (OMPBuilder.createSections (
4302- Builder, AllocaIP, SectionCBVector, PrivCB, FiniCB, S.hasCancel (),
4303- S.getSingleClause <OMPNowaitClause>()));
4314+ llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
4315+ OMPBuilder.createSections (Builder, AllocaIP, SectionCBVector, PrivCB,
4316+ FiniCB, S.hasCancel (),
4317+ S.getSingleClause <OMPNowaitClause>());
4318+ assert (AfterIP && " unexpected error creating sections" );
4319+ Builder.restoreIP (*AfterIP);
43044320 return ;
43054321 }
43064322 {
@@ -4326,17 +4342,22 @@ void CodeGenFunction::EmitOMPSectionDirective(const OMPSectionDirective &S) {
43264342 const Stmt *SectionRegionBodyStmt = S.getAssociatedStmt ();
43274343 auto FiniCB = [this ](InsertPointTy IP) {
43284344 OMPBuilderCBHelpers::FinalizeOMPRegion (*this , IP);
4345+ return llvm::Error::success ();
43294346 };
43304347
43314348 auto BodyGenCB = [SectionRegionBodyStmt, this ](InsertPointTy AllocaIP,
43324349 InsertPointTy CodeGenIP) {
43334350 OMPBuilderCBHelpers::EmitOMPInlinedRegionBody (
43344351 *this , SectionRegionBodyStmt, AllocaIP, CodeGenIP, " section" );
4352+ return llvm::Error::success ();
43354353 };
43364354
43374355 LexicalScope Scope (*this , S.getSourceRange ());
43384356 EmitStopPoint (&S);
4339- Builder.restoreIP (OMPBuilder.createSection (Builder, BodyGenCB, FiniCB));
4357+ llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
4358+ OMPBuilder.createSection (Builder, BodyGenCB, FiniCB);
4359+ assert (AfterIP && " unexpected error creating section" );
4360+ Builder.restoreIP (*AfterIP);
43404361
43414362 return ;
43424363 }
@@ -4407,17 +4428,22 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) {
44074428
44084429 auto FiniCB = [this ](InsertPointTy IP) {
44094430 OMPBuilderCBHelpers::FinalizeOMPRegion (*this , IP);
4431+ return llvm::Error::success ();
44104432 };
44114433
44124434 auto BodyGenCB = [MasterRegionBodyStmt, this ](InsertPointTy AllocaIP,
44134435 InsertPointTy CodeGenIP) {
44144436 OMPBuilderCBHelpers::EmitOMPInlinedRegionBody (
44154437 *this , MasterRegionBodyStmt, AllocaIP, CodeGenIP, " master" );
4438+ return llvm::Error::success ();
44164439 };
44174440
44184441 LexicalScope Scope (*this , S.getSourceRange ());
44194442 EmitStopPoint (&S);
4420- Builder.restoreIP (OMPBuilder.createMaster (Builder, BodyGenCB, FiniCB));
4443+ llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
4444+ OMPBuilder.createMaster (Builder, BodyGenCB, FiniCB);
4445+ assert (AfterIP && " unexpected error creating master" );
4446+ Builder.restoreIP (*AfterIP);
44214447
44224448 return ;
44234449 }
@@ -4453,18 +4479,22 @@ void CodeGenFunction::EmitOMPMaskedDirective(const OMPMaskedDirective &S) {
44534479
44544480 auto FiniCB = [this ](InsertPointTy IP) {
44554481 OMPBuilderCBHelpers::FinalizeOMPRegion (*this , IP);
4482+ return llvm::Error::success ();
44564483 };
44574484
44584485 auto BodyGenCB = [MaskedRegionBodyStmt, this ](InsertPointTy AllocaIP,
44594486 InsertPointTy CodeGenIP) {
44604487 OMPBuilderCBHelpers::EmitOMPInlinedRegionBody (
44614488 *this , MaskedRegionBodyStmt, AllocaIP, CodeGenIP, " masked" );
4489+ return llvm::Error::success ();
44624490 };
44634491
44644492 LexicalScope Scope (*this , S.getSourceRange ());
44654493 EmitStopPoint (&S);
4466- Builder.restoreIP (
4467- OMPBuilder.createMasked (Builder, BodyGenCB, FiniCB, FilterVal));
4494+ llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
4495+ OMPBuilder.createMasked (Builder, BodyGenCB, FiniCB, FilterVal);
4496+ assert (AfterIP && " unexpected error creating masked" );
4497+ Builder.restoreIP (*AfterIP);
44684498
44694499 return ;
44704500 }
@@ -4493,19 +4523,23 @@ void CodeGenFunction::EmitOMPCriticalDirective(const OMPCriticalDirective &S) {
44934523
44944524 auto FiniCB = [this ](InsertPointTy IP) {
44954525 OMPBuilderCBHelpers::FinalizeOMPRegion (*this , IP);
4526+ return llvm::Error::success ();
44964527 };
44974528
44984529 auto BodyGenCB = [CriticalRegionBodyStmt, this ](InsertPointTy AllocaIP,
44994530 InsertPointTy CodeGenIP) {
45004531 OMPBuilderCBHelpers::EmitOMPInlinedRegionBody (
45014532 *this , CriticalRegionBodyStmt, AllocaIP, CodeGenIP, " critical" );
4533+ return llvm::Error::success ();
45024534 };
45034535
45044536 LexicalScope Scope (*this , S.getSourceRange ());
45054537 EmitStopPoint (&S);
4506- Builder.restoreIP (OMPBuilder.createCritical (
4507- Builder, BodyGenCB, FiniCB, S.getDirectiveName ().getAsString (),
4508- HintInst));
4538+ llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
4539+ OMPBuilder.createCritical (Builder, BodyGenCB, FiniCB,
4540+ S.getDirectiveName ().getAsString (), HintInst);
4541+ assert (AfterIP && " unexpected error creating critical" );
4542+ Builder.restoreIP (*AfterIP);
45094543
45104544 return ;
45114545 }
@@ -5464,11 +5498,15 @@ void CodeGenFunction::EmitOMPTaskgroupDirective(
54645498 InsertPointTy CodeGenIP) {
54655499 Builder.restoreIP (CodeGenIP);
54665500 EmitStmt (S.getInnermostCapturedStmt ()->getCapturedStmt ());
5501+ return llvm::Error::success ();
54675502 };
54685503 CodeGenFunction::CGCapturedStmtInfo CapStmtInfo;
54695504 if (!CapturedStmtInfo)
54705505 CapturedStmtInfo = &CapStmtInfo;
5471- Builder.restoreIP (OMPBuilder.createTaskgroup (Builder, AllocaIP, BodyGenCB));
5506+ llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
5507+ OMPBuilder.createTaskgroup (Builder, AllocaIP, BodyGenCB);
5508+ assert (AfterIP && " unexpected error creating taskgroup" );
5509+ Builder.restoreIP (*AfterIP);
54725510 return ;
54735511 }
54745512 auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &Action) {
@@ -6041,6 +6079,7 @@ void CodeGenFunction::EmitOMPOrderedDirective(const OMPOrderedDirective &S) {
60416079
60426080 auto FiniCB = [this ](InsertPointTy IP) {
60436081 OMPBuilderCBHelpers::FinalizeOMPRegion (*this , IP);
6082+ return llvm::Error::success ();
60446083 };
60456084
60466085 auto BodyGenCB = [&S, C, this ](InsertPointTy AllocaIP,
@@ -6064,11 +6103,14 @@ void CodeGenFunction::EmitOMPOrderedDirective(const OMPOrderedDirective &S) {
60646103 OMPBuilderCBHelpers::EmitOMPInlinedRegionBody (
60656104 *this , CS->getCapturedStmt (), AllocaIP, CodeGenIP, " ordered" );
60666105 }
6106+ return llvm::Error::success ();
60676107 };
60686108
60696109 OMPLexicalScope Scope (*this , S, OMPD_unknown);
6070- Builder.restoreIP (
6071- OMPBuilder.createOrderedThreadsSimd (Builder, BodyGenCB, FiniCB, !C));
6110+ llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
6111+ OMPBuilder.createOrderedThreadsSimd (Builder, BodyGenCB, FiniCB, !C);
6112+ assert (AfterIP && " unexpected error creating ordered" );
6113+ Builder.restoreIP (*AfterIP);
60726114 }
60736115 return ;
60746116 }
@@ -7344,8 +7386,10 @@ void CodeGenFunction::EmitOMPCancelDirective(const OMPCancelDirective &S) {
73447386 if (IfCond)
73457387 IfCondition = EmitScalarExpr (IfCond,
73467388 /* IgnoreResultAssign=*/ true );
7347- return Builder.restoreIP (
7348- OMPBuilder.createCancel (Builder, IfCondition, S.getCancelRegion ()));
7389+ llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
7390+ OMPBuilder.createCancel (Builder, IfCondition, S.getCancelRegion ());
7391+ assert (AfterIP && " unexpected error creating cancel" );
7392+ return Builder.restoreIP (*AfterIP);
73497393 }
73507394 }
73517395
0 commit comments