summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
diff options
context:
space:
mode:
authorHeejin Ahn <aheejin@gmail.com>2018-10-25 23:35:13 +0000
committerHeejin Ahn <aheejin@gmail.com>2018-10-25 23:35:13 +0000
commit1147d91402559d0d1193265f81bc854674a1e36f (patch)
tree3da30369e844fcc3cd587eba38da5c0bbe085ea3 /llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
parentcc18f8aa0f3ca35295419e1f4f0322a6cbe3c70b (diff)
downloadbcm5719-llvm-1147d91402559d0d1193265f81bc854674a1e36f.tar.gz
bcm5719-llvm-1147d91402559d0d1193265f81bc854674a1e36f.zip
[WebAssembly] Error out when block/loop markers mismatch
Summary: Currently InstPrinter ignores if there are mismatches between block/loop and end markers by skipping the case if ControlFlowStack is empty. I guess it is better to explicitly error out in this case, because this signals invalid input. Reviewers: aardappel Subscribers: dschuff, sbc100, jgravelle-google, sunfish, llvm-commits Differential Revision: https://reviews.llvm.org/D53620 llvm-svn: 345333
Diffstat (limited to 'llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp b/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
index 08c1155fed7..e26cf1d8cf4 100644
--- a/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
+++ b/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
@@ -85,16 +85,16 @@ void WebAssemblyInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
break;
case WebAssembly::END_LOOP:
case WebAssembly::END_LOOP_S:
- // Have to guard against an empty stack, in case of mismatched pairs
- // in assembly parsing.
- if (!ControlFlowStack.empty())
- ControlFlowStack.pop_back();
+ if (ControlFlowStack.empty())
+ report_fatal_error("End marker mismatch!");
+ ControlFlowStack.pop_back();
break;
case WebAssembly::END_BLOCK:
case WebAssembly::END_BLOCK_S:
- if (!ControlFlowStack.empty())
- printAnnotation(
- OS, "label" + utostr(ControlFlowStack.pop_back_val().first) + ':');
+ if (ControlFlowStack.empty())
+ report_fatal_error("END marker mismatch!");
+ printAnnotation(
+ OS, "label" + utostr(ControlFlowStack.pop_back_val().first) + ':');
break;
}
OpenPOWER on IntegriCloud