diff --git a/lib/IR/Verifier.cpp b/lib/IR/Verifier.cpp index f7807d1e1b0..82dadb47210 100644 --- a/lib/IR/Verifier.cpp +++ b/lib/IR/Verifier.cpp @@ -276,13 +276,14 @@ public: Context = &M->getContext(); // First ensure the function is well-enough formed to compute dominance - // information. - if (F.empty()) { - if (OS) - *OS << "Function '" << F.getName() - << "' does not contain an entry block!\n"; - return false; - } + // information, and directly compute a dominance tree. We don't rely on the + // pass manager to provide this as it isolates us from a potentially + // out-of-date dominator tree and makes it significantly more complex to run + // this code outside of a pass manager. + // FIXME: It's really gross that we have to cast away constness here. + if (!F.empty()) + DT.recalculate(const_cast(F)); + for (const BasicBlock &BB : F) { if (!BB.empty() && BB.back().isTerminator()) continue; @@ -296,13 +297,6 @@ public: return false; } - // Now directly compute a dominance tree. We don't rely on the pass - // manager to provide this as it isolates us from a potentially - // out-of-date dominator tree and makes it significantly more complex to - // run this code outside of a pass manager. - // FIXME: It's really gross that we have to cast away constness here. - DT.recalculate(const_cast(F)); - Broken = false; // FIXME: We strip const here because the inst visitor strips const. visit(const_cast(F));