Skip to content

Commit 137b50f

Browse files
committed
Guard dumps in the coro intrinsic validation logic behind NDEBUG checks. dump() is not guaranteed to be defined in all builds.
llvm-svn: 368790
1 parent 3829214 commit 137b50f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

llvm/lib/Transforms/Coroutines/Coroutines.cpp

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,9 @@ void coro::Shape::buildFrom(Function &F) {
360360
for (auto AnySuspend : CoroSuspends) {
361361
auto Suspend = dyn_cast<CoroSuspendInst>(AnySuspend);
362362
if (!Suspend) {
363+
#ifndef NDEBUG
363364
AnySuspend->dump();
365+
#endif
364366
report_fatal_error("coro.id must be paired with coro.suspend");
365367
}
366368

@@ -392,7 +394,9 @@ void coro::Shape::buildFrom(Function &F) {
392394
for (auto AnySuspend : CoroSuspends) {
393395
auto Suspend = dyn_cast<CoroSuspendRetconInst>(AnySuspend);
394396
if (!Suspend) {
397+
#ifndef NDEBUG
395398
AnySuspend->dump();
399+
#endif
396400
report_fatal_error("coro.id.retcon.* must be paired with "
397401
"coro.suspend.retcon");
398402
}
@@ -402,15 +406,19 @@ void coro::Shape::buildFrom(Function &F) {
402406
auto RI = ResultTys.begin(), RE = ResultTys.end();
403407
for (; SI != SE && RI != RE; ++SI, ++RI) {
404408
if ((*SI)->getType() != *RI) {
409+
#ifndef NDEBUG
405410
Suspend->dump();
406411
Prototype->getFunctionType()->dump();
412+
#endif
407413
report_fatal_error("argument to coro.suspend.retcon does not "
408414
"match corresponding prototype function result");
409415
}
410416
}
411417
if (SI != SE || RI != RE) {
418+
#ifndef NDEBUG
412419
Suspend->dump();
413420
Prototype->getFunctionType()->dump();
421+
#endif
414422
report_fatal_error("wrong number of arguments to coro.suspend.retcon");
415423
}
416424

@@ -421,14 +429,18 @@ void coro::Shape::buildFrom(Function &F) {
421429
? cast<StructType>(SResultTy)->elements()
422430
: SResultTy); // forms an ArrayRef using SResultTy, be careful
423431
if (SuspendResultTys.size() != ResumeTys.size()) {
432+
#ifndef NDEBUG
424433
Suspend->dump();
425434
Prototype->getFunctionType()->dump();
435+
#endif
426436
report_fatal_error("wrong number of results from coro.suspend.retcon");
427437
}
428438
for (size_t I = 0, E = ResumeTys.size(); I != E; ++I) {
429439
if (SuspendResultTys[I] != ResumeTys[I]) {
440+
#ifndef NDEBUG
430441
Suspend->dump();
431442
Prototype->getFunctionType()->dump();
443+
#endif
432444
report_fatal_error("result from coro.suspend.retcon does not "
433445
"match corresponding prototype function param");
434446
}
@@ -509,12 +521,14 @@ void coro::Shape::emitDealloc(IRBuilder<> &Builder, Value *Ptr,
509521

510522
LLVM_ATTRIBUTE_NORETURN
511523
static void fail(const Instruction *I, const char *Reason, Value *V) {
524+
#ifndef NDEBUG
512525
I->dump();
513526
if (V) {
514527
errs() << " Value: ";
515528
V->printAsOperand(llvm::errs());
516529
errs() << '\n';
517530
}
531+
#endif
518532
report_fatal_error(Reason);
519533
}
520534

0 commit comments

Comments
 (0)