[clang] [llvm] [OpenMP][OMPIRBuilder] Handle non-failing calls properly (PR #115863)
via cfe-commits
cfe-commits at lists.llvm.org
Tue Nov 12 04:50:07 PST 2024
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-clang
@llvm/pr-subscribers-clang-codegen
Author: Sergio Afonso (skatrak)
<details>
<summary>Changes</summary>
The preprocessor definition used to enable asserts and the one that `llvm::Error` and `llvm::Expected` use to ensure all created instances are checked are not the same. By making these checks inside of an `assert` in cases where errors are not expected, certain build configurations would trigger runtime failures.
The `llvm::cantFail()` function, which was intended for this use case, is used by this patch in place of `assert` to prevent these runtime failures.
---
Patch is 76.82 KiB, truncated to 20.00 KiB below, full version: https://github.com/llvm/llvm-project/pull/115863.diff
6 Files Affected:
- (modified) clang/lib/CodeGen/CGOpenMPRuntime.cpp (+14-18)
- (modified) clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp (+4-5)
- (modified) clang/lib/CodeGen/CGStmtOpenMP.cpp (+38-50)
- (modified) llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp (+12-20)
- (modified) llvm/lib/Transforms/IPO/OpenMPOpt.cpp (+13-19)
- (modified) llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp (+272-363)
``````````diff
diff --git a/clang/lib/CodeGen/CGOpenMPRuntime.cpp b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
index d714af035d21a2..9c22103a1a75c6 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntime.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntime.cpp
@@ -2332,11 +2332,10 @@ void CGOpenMPRuntime::emitBarrierCall(CodeGenFunction &CGF, SourceLocation Loc,
auto *OMPRegionInfo =
dyn_cast_or_null<CGOpenMPRegionInfo>(CGF.CapturedStmtInfo);
if (CGF.CGM.getLangOpts().OpenMPIRBuilder) {
- llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
- OMPBuilder.createBarrier(CGF.Builder, Kind, ForceSimpleCall,
- EmitChecks);
- assert(AfterIP && "unexpected error creating barrier");
- CGF.Builder.restoreIP(*AfterIP);
+ llvm::OpenMPIRBuilder::InsertPointTy AfterIP =
+ cantFail(OMPBuilder.createBarrier(CGF.Builder, Kind, ForceSimpleCall,
+ EmitChecks));
+ CGF.Builder.restoreIP(AfterIP);
return;
}
@@ -5932,10 +5931,9 @@ void CGOpenMPRuntime::emitTargetOutlinedFunctionHelper(
return CGF.GenerateOpenMPCapturedStmtFunction(CS, D.getBeginLoc());
};
- llvm::Error Err = OMPBuilder.emitTargetRegionFunction(
+ cantFail(OMPBuilder.emitTargetRegionFunction(
EntryInfo, GenerateOutlinedFunction, IsOffloadEntry, OutlinedFn,
- OutlinedFnID);
- assert(!Err && "unexpected error creating target region");
+ OutlinedFnID));
if (!OutlinedFn)
return;
@@ -9676,12 +9674,11 @@ static void emitTargetCallKernelLaunch(
NumTargetItems, RTArgs, NumIterations, NumTeams, NumThreads,
DynCGGroupMem, HasNoWait);
- llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
- OMPRuntime->getOMPBuilder().emitKernelLaunch(
+ llvm::OpenMPIRBuilder::InsertPointTy AfterIP =
+ cantFail(OMPRuntime->getOMPBuilder().emitKernelLaunch(
CGF.Builder, OutlinedFnID, EmitTargetCallFallbackCB, Args, DeviceID,
- RTLoc, AllocaIP);
- assert(AfterIP && "unexpected error creating kernel launch");
- CGF.Builder.restoreIP(*AfterIP);
+ RTLoc, AllocaIP));
+ CGF.Builder.restoreIP(AfterIP);
};
if (RequiresOuterTask)
@@ -10358,12 +10355,11 @@ void CGOpenMPRuntime::emitTargetDataCalls(
InsertPointTy CodeGenIP(CGF.Builder.GetInsertBlock(),
CGF.Builder.GetInsertPoint());
llvm::OpenMPIRBuilder::LocationDescription OmpLoc(CodeGenIP);
- llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
- OMPBuilder.createTargetData(
+ llvm::OpenMPIRBuilder::InsertPointTy AfterIP =
+ cantFail(OMPBuilder.createTargetData(
OmpLoc, AllocaIP, CodeGenIP, DeviceID, IfCondVal, Info, GenMapInfoCB,
- /*MapperFunc=*/nullptr, BodyCB, DeviceAddrCB, CustomMapperCB, RTLoc);
- assert(AfterIP && "unexpected error creating target data");
- CGF.Builder.restoreIP(*AfterIP);
+ /*MapperFunc=*/nullptr, BodyCB, DeviceAddrCB, CustomMapperCB, RTLoc));
+ CGF.Builder.restoreIP(AfterIP);
}
void CGOpenMPRuntime::emitTargetDataStandAloneCall(
diff --git a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
index 598b946ad88dbb..a794175060e41c 100644
--- a/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
+++ b/clang/lib/CodeGen/CGOpenMPRuntimeGPU.cpp
@@ -1753,14 +1753,13 @@ void CGOpenMPRuntimeGPU::emitReduction(
Idx++;
}
- llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
- OMPBuilder.createReductionsGPU(
+ llvm::OpenMPIRBuilder::InsertPointTy AfterIP =
+ cantFail(OMPBuilder.createReductionsGPU(
OmpLoc, AllocaIP, CodeGenIP, ReductionInfos, false, TeamsReduction,
DistributeReduction, llvm::OpenMPIRBuilder::ReductionGenCBKind::Clang,
CGF.getTarget().getGridValue(),
- C.getLangOpts().OpenMPCUDAReductionBufNum, RTLoc);
- assert(AfterIP && "unexpected error creating GPU reductions");
- CGF.Builder.restoreIP(*AfterIP);
+ C.getLangOpts().OpenMPCUDAReductionBufNum, RTLoc));
+ CGF.Builder.restoreIP(AfterIP);
return;
}
diff --git a/clang/lib/CodeGen/CGStmtOpenMP.cpp b/clang/lib/CodeGen/CGStmtOpenMP.cpp
index 390516fea38498..ad1453ddbaaec2 100644
--- a/clang/lib/CodeGen/CGStmtOpenMP.cpp
+++ b/clang/lib/CodeGen/CGStmtOpenMP.cpp
@@ -1839,11 +1839,10 @@ void CodeGenFunction::EmitOMPParallelDirective(const OMPParallelDirective &S) {
CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(*this, &CGSI);
llvm::OpenMPIRBuilder::InsertPointTy AllocaIP(
AllocaInsertPt->getParent(), AllocaInsertPt->getIterator());
- llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
+ llvm::OpenMPIRBuilder::InsertPointTy AfterIP = cantFail(
OMPBuilder.createParallel(Builder, AllocaIP, BodyGenCB, PrivCB, FiniCB,
- IfCond, NumThreads, ProcBind, S.hasCancel());
- assert(AfterIP && "unexpected error creating parallel");
- Builder.restoreIP(*AfterIP);
+ IfCond, NumThreads, ProcBind, S.hasCancel()));
+ Builder.restoreIP(AfterIP);
return;
}
@@ -2135,10 +2134,8 @@ void CodeGenFunction::EmitOMPCanonicalLoop(const OMPCanonicalLoop *S) {
return llvm::Error::success();
};
- llvm::Expected<llvm::CanonicalLoopInfo *> Result =
- OMPBuilder.createCanonicalLoop(Builder, BodyGen, DistVal);
- assert(Result && "unexpected error creating canonical loop");
- llvm::CanonicalLoopInfo *CL = *Result;
+ llvm::CanonicalLoopInfo *CL =
+ cantFail(OMPBuilder.createCanonicalLoop(Builder, BodyGen, DistVal));
// Finish up the loop.
Builder.restoreIP(CL->getAfterIP());
@@ -4024,13 +4021,11 @@ static void emitOMPForDirective(const OMPLoopDirective &S, CodeGenFunction &CGF,
CGM.getOpenMPRuntime().getOMPBuilder();
llvm::OpenMPIRBuilder::InsertPointTy AllocaIP(
CGF.AllocaInsertPt->getParent(), CGF.AllocaInsertPt->getIterator());
- llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
- OMPBuilder.applyWorkshareLoop(
- CGF.Builder.getCurrentDebugLocation(), CLI, AllocaIP,
- NeedsBarrier, SchedKind, ChunkSize, /*HasSimdModifier=*/false,
- /*HasMonotonicModifier=*/false, /*HasNonmonotonicModifier=*/false,
- /*HasOrderedClause=*/false);
- assert(AfterIP && "unexpected error creating workshare loop");
+ cantFail(OMPBuilder.applyWorkshareLoop(
+ CGF.Builder.getCurrentDebugLocation(), CLI, AllocaIP, NeedsBarrier,
+ SchedKind, ChunkSize, /*HasSimdModifier=*/false,
+ /*HasMonotonicModifier=*/false, /*HasNonmonotonicModifier=*/false,
+ /*HasOrderedClause=*/false));
return;
}
@@ -4311,12 +4306,11 @@ void CodeGenFunction::EmitOMPSectionsDirective(const OMPSectionsDirective &S) {
CodeGenFunction::CGCapturedStmtRAII CapInfoRAII(*this, &CGSI);
llvm::OpenMPIRBuilder::InsertPointTy AllocaIP(
AllocaInsertPt->getParent(), AllocaInsertPt->getIterator());
- llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
- OMPBuilder.createSections(Builder, AllocaIP, SectionCBVector, PrivCB,
- FiniCB, S.hasCancel(),
- S.getSingleClause<OMPNowaitClause>());
- assert(AfterIP && "unexpected error creating sections");
- Builder.restoreIP(*AfterIP);
+ llvm::OpenMPIRBuilder::InsertPointTy AfterIP =
+ cantFail(OMPBuilder.createSections(
+ Builder, AllocaIP, SectionCBVector, PrivCB, FiniCB, S.hasCancel(),
+ S.getSingleClause<OMPNowaitClause>()));
+ Builder.restoreIP(AfterIP);
return;
}
{
@@ -4354,10 +4348,9 @@ void CodeGenFunction::EmitOMPSectionDirective(const OMPSectionDirective &S) {
LexicalScope Scope(*this, S.getSourceRange());
EmitStopPoint(&S);
- llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
- OMPBuilder.createSection(Builder, BodyGenCB, FiniCB);
- assert(AfterIP && "unexpected error creating section");
- Builder.restoreIP(*AfterIP);
+ llvm::OpenMPIRBuilder::InsertPointTy AfterIP =
+ cantFail(OMPBuilder.createSection(Builder, BodyGenCB, FiniCB));
+ Builder.restoreIP(AfterIP);
return;
}
@@ -4440,10 +4433,9 @@ void CodeGenFunction::EmitOMPMasterDirective(const OMPMasterDirective &S) {
LexicalScope Scope(*this, S.getSourceRange());
EmitStopPoint(&S);
- llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
- OMPBuilder.createMaster(Builder, BodyGenCB, FiniCB);
- assert(AfterIP && "unexpected error creating master");
- Builder.restoreIP(*AfterIP);
+ llvm::OpenMPIRBuilder::InsertPointTy AfterIP =
+ cantFail(OMPBuilder.createMaster(Builder, BodyGenCB, FiniCB));
+ Builder.restoreIP(AfterIP);
return;
}
@@ -4491,10 +4483,9 @@ void CodeGenFunction::EmitOMPMaskedDirective(const OMPMaskedDirective &S) {
LexicalScope Scope(*this, S.getSourceRange());
EmitStopPoint(&S);
- llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
- OMPBuilder.createMasked(Builder, BodyGenCB, FiniCB, FilterVal);
- assert(AfterIP && "unexpected error creating masked");
- Builder.restoreIP(*AfterIP);
+ llvm::OpenMPIRBuilder::InsertPointTy AfterIP = cantFail(
+ OMPBuilder.createMasked(Builder, BodyGenCB, FiniCB, FilterVal));
+ Builder.restoreIP(AfterIP);
return;
}
@@ -4535,11 +4526,11 @@ void CodeGenFunction::EmitOMPCriticalDirective(const OMPCriticalDirective &S) {
LexicalScope Scope(*this, S.getSourceRange());
EmitStopPoint(&S);
- llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
- OMPBuilder.createCritical(Builder, BodyGenCB, FiniCB,
- S.getDirectiveName().getAsString(), HintInst);
- assert(AfterIP && "unexpected error creating critical");
- Builder.restoreIP(*AfterIP);
+ llvm::OpenMPIRBuilder::InsertPointTy AfterIP =
+ cantFail(OMPBuilder.createCritical(Builder, BodyGenCB, FiniCB,
+ S.getDirectiveName().getAsString(),
+ HintInst));
+ Builder.restoreIP(AfterIP);
return;
}
@@ -5503,10 +5494,9 @@ void CodeGenFunction::EmitOMPTaskgroupDirective(
CodeGenFunction::CGCapturedStmtInfo CapStmtInfo;
if (!CapturedStmtInfo)
CapturedStmtInfo = &CapStmtInfo;
- llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
- OMPBuilder.createTaskgroup(Builder, AllocaIP, BodyGenCB);
- assert(AfterIP && "unexpected error creating taskgroup");
- Builder.restoreIP(*AfterIP);
+ llvm::OpenMPIRBuilder::InsertPointTy AfterIP =
+ cantFail(OMPBuilder.createTaskgroup(Builder, AllocaIP, BodyGenCB));
+ Builder.restoreIP(AfterIP);
return;
}
auto &&CodeGen = [&S](CodeGenFunction &CGF, PrePostActionTy &Action) {
@@ -6109,10 +6099,9 @@ void CodeGenFunction::EmitOMPOrderedDirective(const OMPOrderedDirective &S) {
};
OMPLexicalScope Scope(*this, S, OMPD_unknown);
- llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
- OMPBuilder.createOrderedThreadsSimd(Builder, BodyGenCB, FiniCB, !C);
- assert(AfterIP && "unexpected error creating ordered");
- Builder.restoreIP(*AfterIP);
+ llvm::OpenMPIRBuilder::InsertPointTy AfterIP = cantFail(
+ OMPBuilder.createOrderedThreadsSimd(Builder, BodyGenCB, FiniCB, !C));
+ Builder.restoreIP(AfterIP);
}
return;
}
@@ -7388,10 +7377,9 @@ void CodeGenFunction::EmitOMPCancelDirective(const OMPCancelDirective &S) {
if (IfCond)
IfCondition = EmitScalarExpr(IfCond,
/*IgnoreResultAssign=*/true);
- llvm::OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
- OMPBuilder.createCancel(Builder, IfCondition, S.getCancelRegion());
- assert(AfterIP && "unexpected error creating cancel");
- return Builder.restoreIP(*AfterIP);
+ llvm::OpenMPIRBuilder::InsertPointTy AfterIP = cantFail(
+ OMPBuilder.createCancel(Builder, IfCondition, S.getCancelRegion()));
+ return Builder.restoreIP(AfterIP);
}
}
diff --git a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
index d2e4dc1c85dfd2..5d9a7784d9e68c 100644
--- a/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
+++ b/llvm/lib/Frontend/OpenMP/OMPIRBuilder.cpp
@@ -4225,7 +4225,11 @@ OpenMPIRBuilder::applyStaticChunkedWorkshareLoop(DebugLoc DL,
// Create outer "dispatch" loop for enumerating the chunks.
BasicBlock *DispatchEnter = splitBB(Builder, true);
Value *DispatchCounter;
- Expected<CanonicalLoopInfo *> LoopResult = createCanonicalLoop(
+
+ // It is safe to assume this didn't return an error because the callback
+ // passed into createCanonicalLoop is the only possible error source, and it
+ // always returns success.
+ CanonicalLoopInfo *DispatchCLI = cantFail(createCanonicalLoop(
{Builder.saveIP(), DL},
[&](InsertPointTy BodyIP, Value *Counter) {
DispatchCounter = Counter;
@@ -4233,15 +4237,7 @@ OpenMPIRBuilder::applyStaticChunkedWorkshareLoop(DebugLoc DL,
},
FirstChunkStart, CastedTripCount, NextChunkStride,
/*IsSigned=*/false, /*InclusiveStop=*/false, /*ComputeIP=*/{},
- "dispatch");
- if (!LoopResult) {
- // It is safe to assume this didn't return an error because the callback
- // passed into createCanonicalLoop is the only possible error source, and it
- // always returns success. Need to still cast the result into bool to avoid
- // runtime errors.
- llvm_unreachable("unexpected error creating canonical loop");
- }
- CanonicalLoopInfo *DispatchCLI = *LoopResult;
+ "dispatch"));
// Remember the BasicBlocks of the dispatch loop we need, then invalidate to
// not have to preserve the canonical invariant.
@@ -6542,16 +6538,12 @@ OpenMPIRBuilder::InsertPointOrErrorTy OpenMPIRBuilder::createTargetData(
};
bool RequiresOuterTargetTask = Info.HasNoWait;
- if (!RequiresOuterTargetTask) {
- Error Err = TaskBodyCB(/*DeviceID=*/nullptr, /*RTLoc=*/nullptr,
- /*TargetTaskAllocaIP=*/{});
- assert(!Err && "TaskBodyCB expected to succeed");
- } else {
- InsertPointOrErrorTy AfterIP =
- emitTargetTask(TaskBodyCB, DeviceID, SrcLocInfo, AllocaIP,
- /*Dependencies=*/{}, Info.HasNoWait);
- assert(AfterIP && "TaskBodyCB expected to succeed");
- }
+ if (!RequiresOuterTargetTask)
+ cantFail(TaskBodyCB(/*DeviceID=*/nullptr, /*RTLoc=*/nullptr,
+ /*TargetTaskAllocaIP=*/{}));
+ else
+ cantFail(emitTargetTask(TaskBodyCB, DeviceID, SrcLocInfo, AllocaIP,
+ /*Dependencies=*/{}, Info.HasNoWait));
} else {
Function *BeginMapperFunc = getOrCreateRuntimeFunctionPtr(
omp::OMPRTL___tgt_target_data_begin_mapper);
diff --git a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
index 9e25620710fc84..153f5c7510efae 100644
--- a/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
+++ b/llvm/lib/Transforms/IPO/OpenMPOpt.cpp
@@ -1178,15 +1178,12 @@ struct OpenMPOpt {
OpenMPIRBuilder::LocationDescription Loc(
InsertPointTy(ParentBB, ParentBB->end()), DL);
- OpenMPIRBuilder::InsertPointOrErrorTy SeqAfterIP =
- OMPInfoCache.OMPBuilder.createMaster(Loc, BodyGenCB, FiniCB);
- assert(SeqAfterIP && "Unexpected error creating master");
+ OpenMPIRBuilder::InsertPointTy SeqAfterIP = cantFail(
+ OMPInfoCache.OMPBuilder.createMaster(Loc, BodyGenCB, FiniCB));
+ cantFail(
+ OMPInfoCache.OMPBuilder.createBarrier(SeqAfterIP, OMPD_parallel));
- OpenMPIRBuilder::InsertPointOrErrorTy BarrierAfterIP =
- OMPInfoCache.OMPBuilder.createBarrier(*SeqAfterIP, OMPD_parallel);
- assert(BarrierAfterIP && "Unexpected error creating barrier");
-
- BranchInst::Create(SeqAfterBB, SeqAfterIP->getBlock());
+ BranchInst::Create(SeqAfterBB, SeqAfterIP.getBlock());
LLVM_DEBUG(dbgs() << TAG << "After sequential inlining " << *OuterFn
<< "\n");
@@ -1256,12 +1253,11 @@ struct OpenMPOpt {
OriginalFn->getEntryBlock().getFirstInsertionPt());
// Create the merged parallel region with default proc binding, to
// avoid overriding binding settings, and without explicit cancellation.
- OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
- OMPInfoCache.OMPBuilder.createParallel(
+ OpenMPIRBuilder::InsertPointTy AfterIP =
+ cantFail(OMPInfoCache.OMPBuilder.createParallel(
Loc, AllocaIP, BodyGenCB, PrivCB, FiniCB, nullptr, nullptr,
- OMP_PROC_BIND_default, /* IsCancellable */ false);
- assert(AfterIP && "Unexpected error creating parallel");
- BranchInst::Create(AfterBB, AfterIP->getBlock());
+ OMP_PROC_BIND_default, /* IsCancellable */ false));
+ BranchInst::Create(AfterBB, AfterIP.getBlock());
// Perform the actual outlining.
OMPInfoCache.OMPBuilder.finalize(OriginalFn);
@@ -1297,12 +1293,10 @@ struct OpenMPOpt {
if (CI != MergableCIs.back()) {
// TODO: Remove barrier if the merged parallel region includes the
// 'nowait' clause.
- OpenMPIRBuilder::InsertPointOrErrorTy AfterIP =
- OMPInfoCache.OMPBuilder.createBarrier(
- InsertPointTy(NewCI->getParent(),
- NewCI->getNextNode()->getIterator()),
- OMPD_parallel);
- assert(AfterIP && "Unexpected error creating barrier");
+ cantFail(OMPInfoCache.OMPBuilder.createBarrier(
+ InsertPointTy(NewCI->getParent(),
+ NewCI->getNextNode()->getIterator()),
+ OMPD_parallel));
}
CI->eraseFromParent();
diff --git a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
index 630cd03c688012..dfdb5d69501ed4 100644
--- a/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
+++ b/llvm/unittests/Frontend/OpenMPIRBuilderTest.cpp
@@ -235,10 +235,9 @@ class OpenMPIRBuilderTest : public testing::Test {
return Error::success();
};
- Expected<CanonicalLoopInfo *> LoopResult =
- OMPBuilder.createCanonicalLoop(Loc, LoopBodyGenCB, CastedTripCount);
- assert(LoopResult && "unexpected error");
- CanonicalLoopInfo *Loop = *LoopResult;
+
+ CanonicalLoopInfo *Loop = cantFail(
+ OMPBuilder.createCanonicalLoop(Loc, LoopBodyGenCB, CastedTripCount));
// Finalize the function.
Builder.restoreIP(Loop->getAfterIP());
@@ -345,18 +344,14 @@ TEST_F(OpenMPIRBuilderTest, CreateBarrier) {
IRBuilder<> Builder(BB);
- OpenMPIRBuilder::InsertPointOrErrorTy BarrierIP1 =
- OMPBuilder.createBarrier({IRBuilder<>::InsertPoint()}, OMPD_for);
- assert(BarrierIP1 && "unexpected error");
+ cantFail(OMPBuilder.createBarrier({IRBuilder<>::InsertPoint()}, OMPD_for));
EXPECT_TRUE(M->global_empty());
EXPECT_EQ(M->size(), 1U);
EXPECT_EQ(F->size(), 1U);
EXPECT_EQ(BB->size(), 0U);
OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP()});
- OpenMPIRBuilder::InsertPointOrErrorTy BarrierIP2 =
- OMPBuilder.createBarrier(Loc, OMPD_for);
- assert(BarrierIP2 && "unexpected error");
+ cantFail(OMPBuilder.createBarrier(Loc, OMPD_for));
EXPECT_FALSE(M->global_empty());
EXPECT_EQ(M->size(), 3U);
EXPECT_EQ(F->size(), 1U);
@@ -399,10 +394,9 @@ TEST_F(OpenMPIRBuilderTest, CreateCancel) {
IRBuilder<> Builder(BB);
OpenMPIRBuilder::LocationDescription Loc({Builder.saveIP()});
- OpenMPIRBuilder::InsertPointOrErrorTy NewIP =
- OMPBuilder.createCancel(Loc, nullptr, OMPD_parallel);
- assert(NewIP && "unexpected error");
- Builder.restoreIP(*NewIP);
+ OpenMPIRBuilder::InsertPointTy NewIP =
+ cantFail(OMPBuilder.createCancel(Loc, nullptr, OMPD_parallel));
+ Builder.restoreIP(NewIP);
EXPECT_FALSE(M->global_empty());
EXPECT_EQ(M->size(), 4U);
EXPECT_EQ(F->size(), 4U);
@@ -424,7 +418,7 @@ TEST_F(OpenMPIRBuilderTest, CreateCancel) {
EXPECT_EQ(Cancel->getNumUses(), 1U);
Instruction *CancelBBTI = Cancel->getParent()->getTerminator();
EXPECT_EQ(CancelBBTI->getNumSuccessors(), 2U);
- EXPECT_EQ(CancelBBTI->getSuccessor(0), NewIP->getBlock());
+ EXPECT_EQ(CancelBBTI->getSuccessor(...
[truncated]
``````````
</details>
https://github.com/llvm/llvm-project/pull/115863
More information about the cfe-commits
mailing list