From 2b8158f441da74d8432c7629b005a7107a44186b Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Tue, 17 Apr 2018 21:19:21 +0000 Subject: [PATCH] [WebAssembly] Add an assertion for an invalid CFG Summary: It was not easy to provide a test case for D45648 (rL330079) because the bug didn't manifest itself in the set of currently valid IRs. Added an assertion to check this faster, thanks to @dblaikie's suggestion. Reviewers: dblaikie Subscribers: jfb, dschuff, sbc100, jgravelle-google, llvm-commits, dblaikie Differential Revision: https://reviews.llvm.org/D45711 llvm-svn: 330217 --- llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp index 12664e6..9e0a945 100644 --- a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp +++ b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp @@ -145,6 +145,9 @@ static void PlaceBlockMarker( std::prev(InsertPos)->getOpcode() != WebAssembly::END_LOOP) --InsertPos; } + // The header block in which a 'block' mark will be inserted should have a + // terminator because it is branching to a non-layout successor. + assert(InsertPos != Header->end()); // Add the BLOCK. MachineInstr *Begin = -- 2.7.4