Index: llvm/include/llvm/Support/Error.h =================================================================== --- llvm/include/llvm/Support/Error.h +++ llvm/include/llvm/Support/Error.h @@ -246,20 +246,31 @@ } private: - void assertIsChecked() { #if LLVM_ENABLE_ABI_BREAKING_CHECKS - if (!getChecked() || getPtr()) { - dbgs() << "Program aborted due to an unhandled Error:\n"; - if (getPtr()) - getPtr()->log(dbgs()); - else - dbgs() - << "Error value was Success. (Note: Success values must still be " - "checked prior to being destroyed).\n"; - abort(); - } -#endif + // assertIsChecked() happens very frequently, but under normal circumstances + // is supposed to be a no-op. So we want it to be inlined, but having a bunch + // of debug prints can cause the function to be too large for inlining. So + // we hint the compiler by making sure the unlikely path doesn't get inlined, + // which should guarantee that the fast path does get inlined. + LLVM_ATTRIBUTE_NOINLINE + void fatalUncheckedError() const { + dbgs() << "Program aborted due to an unhandled Error:\n"; + if (getPtr()) + getPtr()->log(dbgs()); + else + dbgs() << "Error value was Success. (Note: Success values must still be " + "checked prior to being destroyed).\n"; + abort(); + } + + void assertIsChecked() { + if (LLVM_UNLIKELY(!getChecked() || getPtr())) + fatalUncheckedError(); + } +#else + void assertIsChecked() { } +#endif ErrorInfoBase *getPtr() const { return reinterpret_cast(