From 1d13e6be37e90851a6ad05a25eb21830857d784e Mon Sep 17 00:00:00 2001 From: Heejin Ahn Date: Thu, 25 Oct 2018 23:35:14 +0000 Subject: [PATCH] Address comments - Add llvm-mc test case (and delete the old one) - Change report_fatal_error to assertions llvm-svn: 345334 --- .../InstPrinter/WebAssemblyInstPrinter.cpp | 6 ++---- .../CodeGen/WebAssembly/block-mismatch.mir | 18 ------------------ llvm/test/MC/WebAssembly/block-mismatch.s | 13 +++++++++++++ 3 files changed, 15 insertions(+), 22 deletions(-) delete mode 100644 llvm/test/CodeGen/WebAssembly/block-mismatch.mir create mode 100644 llvm/test/MC/WebAssembly/block-mismatch.s diff --git a/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp b/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp index e26cf1d8cf4f..33b224adc6e2 100644 --- a/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp +++ b/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp @@ -85,14 +85,12 @@ void WebAssemblyInstPrinter::printInst(const MCInst *MI, raw_ostream &OS, break; case WebAssembly::END_LOOP: case WebAssembly::END_LOOP_S: - if (ControlFlowStack.empty()) - report_fatal_error("End marker mismatch!"); + assert(!ControlFlowStack.empty() && "End marker mismatch!"); ControlFlowStack.pop_back(); break; case WebAssembly::END_BLOCK: case WebAssembly::END_BLOCK_S: - if (ControlFlowStack.empty()) - report_fatal_error("END marker mismatch!"); + assert(!ControlFlowStack.empty() && "End marker mismatch!"); printAnnotation( OS, "label" + utostr(ControlFlowStack.pop_back_val().first) + ':'); break; diff --git a/llvm/test/CodeGen/WebAssembly/block-mismatch.mir b/llvm/test/CodeGen/WebAssembly/block-mismatch.mir deleted file mode 100644 index 0da58e9ddb82..000000000000 --- a/llvm/test/CodeGen/WebAssembly/block-mismatch.mir +++ /dev/null @@ -1,18 +0,0 @@ -# RUN: not llc -mtriple=wasm32-unknown-unknown -start-after xray-instrumentation %s -o /dev/null 2>&1 | FileCheck %s - -# This tests if there are block/loop marker mismatches, the program crashes. - ---- -name: block_mismatch -liveins: - - { reg: '$arguments', reg: '$value_stack' } -tracksRegLiveness: true -body: | - bb.0: - liveins: $arguments, $value_stack - BLOCK 64, implicit-def $value_stack, implicit $value_stack - END_BLOCK implicit-def $value_stack, implicit $value_stack - ; CHECK: LLVM ERROR: END marker mismatch! - END_BLOCK implicit-def $value_stack, implicit $value_stack - RETURN_VOID implicit-def dead $arguments -... diff --git a/llvm/test/MC/WebAssembly/block-mismatch.s b/llvm/test/MC/WebAssembly/block-mismatch.s new file mode 100644 index 000000000000..586407a054ab --- /dev/null +++ b/llvm/test/MC/WebAssembly/block-mismatch.s @@ -0,0 +1,13 @@ +# RUN: not llvm-mc -triple=wasm32-unknown-unknown %s -o - 2>&1 | FileCheck %s + +# This tests if there are block/loop marker mismatches, the program crashes. + .text + .type test0,@function +test0: + block + end_block + # CHECK: End marker mismatch! + end_block + end_function +.Lfunc_end1: + .size test1, .Lfunc_end1-test1