[llvm] r368790 - Guard dumps in the coro intrinsic validation logic behind NDEBUG checks. dump() is not guaranteed to be defined in all builds.
John McCall via llvm-commits
llvm-commits at lists.llvm.org
Tue Aug 13 20:53:32 PDT 2019
Author: rjmccall
Date: Tue Aug 13 20:53:31 2019
New Revision: 368790
URL: http://llvm.org/viewvc/llvm-project?rev=368790&view=rev
Log:
Guard dumps in the coro intrinsic validation logic behind NDEBUG checks. dump() is not guaranteed to be defined in all builds.
Modified:
llvm/trunk/lib/Transforms/Coroutines/Coroutines.cpp
Modified: llvm/trunk/lib/Transforms/Coroutines/Coroutines.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Coroutines/Coroutines.cpp?rev=368790&r1=368789&r2=368790&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Coroutines/Coroutines.cpp (original)
+++ llvm/trunk/lib/Transforms/Coroutines/Coroutines.cpp Tue Aug 13 20:53:31 2019
@@ -360,7 +360,9 @@ void coro::Shape::buildFrom(Function &F)
for (auto AnySuspend : CoroSuspends) {
auto Suspend = dyn_cast<CoroSuspendInst>(AnySuspend);
if (!Suspend) {
+#ifndef NDEBUG
AnySuspend->dump();
+#endif
report_fatal_error("coro.id must be paired with coro.suspend");
}
@@ -392,7 +394,9 @@ void coro::Shape::buildFrom(Function &F)
for (auto AnySuspend : CoroSuspends) {
auto Suspend = dyn_cast<CoroSuspendRetconInst>(AnySuspend);
if (!Suspend) {
+#ifndef NDEBUG
AnySuspend->dump();
+#endif
report_fatal_error("coro.id.retcon.* must be paired with "
"coro.suspend.retcon");
}
@@ -402,15 +406,19 @@ void coro::Shape::buildFrom(Function &F)
auto RI = ResultTys.begin(), RE = ResultTys.end();
for (; SI != SE && RI != RE; ++SI, ++RI) {
if ((*SI)->getType() != *RI) {
+#ifndef NDEBUG
Suspend->dump();
Prototype->getFunctionType()->dump();
+#endif
report_fatal_error("argument to coro.suspend.retcon does not "
"match corresponding prototype function result");
}
}
if (SI != SE || RI != RE) {
+#ifndef NDEBUG
Suspend->dump();
Prototype->getFunctionType()->dump();
+#endif
report_fatal_error("wrong number of arguments to coro.suspend.retcon");
}
@@ -421,14 +429,18 @@ void coro::Shape::buildFrom(Function &F)
? cast<StructType>(SResultTy)->elements()
: SResultTy); // forms an ArrayRef using SResultTy, be careful
if (SuspendResultTys.size() != ResumeTys.size()) {
+#ifndef NDEBUG
Suspend->dump();
Prototype->getFunctionType()->dump();
+#endif
report_fatal_error("wrong number of results from coro.suspend.retcon");
}
for (size_t I = 0, E = ResumeTys.size(); I != E; ++I) {
if (SuspendResultTys[I] != ResumeTys[I]) {
+#ifndef NDEBUG
Suspend->dump();
Prototype->getFunctionType()->dump();
+#endif
report_fatal_error("result from coro.suspend.retcon does not "
"match corresponding prototype function param");
}
@@ -509,12 +521,14 @@ void coro::Shape::emitDealloc(IRBuilder<
LLVM_ATTRIBUTE_NORETURN
static void fail(const Instruction *I, const char *Reason, Value *V) {
+#ifndef NDEBUG
I->dump();
if (V) {
errs() << " Value: ";
V->printAsOperand(llvm::errs());
errs() << '\n';
}
+#endif
report_fatal_error(Reason);
}
More information about the llvm-commits
mailing list