summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
diff options
context:
space:
mode:
authorRichard Trieu <rtrieu@google.com>2018-08-11 04:18:05 +0000
committerRichard Trieu <rtrieu@google.com>2018-08-11 04:18:05 +0000
commit01f99f3cd67bb51a9fc18aa95dc73be20a22288d (patch)
treee755d2d50cada60aeade6f6df3db9e7dcbe7a798 /llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
parent9b6cd711d6dbaffe14664a03b928631f01ace24a (diff)
downloadbcm5719-llvm-01f99f3cd67bb51a9fc18aa95dc73be20a22288d.tar.gz
bcm5719-llvm-01f99f3cd67bb51a9fc18aa95dc73be20a22288d.zip
Fix WebAssembly instruction printer after r339474
Treat the stack variants of control instructions the same as regular instructions. Otherwise, the vector ControlFlowStack will be the wrong size and have out-of-bounds access. This was detected by MemorySanitizer. llvm-svn: 339495
Diffstat (limited to 'llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp b/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
index c040c81aae5..99c814612f7 100644
--- a/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
+++ b/llvm/lib/Target/WebAssembly/InstPrinter/WebAssemblyInstPrinter.cpp
@@ -73,20 +73,24 @@ void WebAssemblyInstPrinter::printInst(const MCInst *MI, raw_ostream &OS,
switch (MI->getOpcode()) {
default:
break;
- case WebAssembly::LOOP: {
+ case WebAssembly::LOOP:
+ case WebAssembly::LOOP_S: {
printAnnotation(OS, "label" + utostr(ControlFlowCounter) + ':');
ControlFlowStack.push_back(std::make_pair(ControlFlowCounter++, true));
break;
}
case WebAssembly::BLOCK:
+ case WebAssembly::BLOCK_S:
ControlFlowStack.push_back(std::make_pair(ControlFlowCounter++, false));
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();
break;
case WebAssembly::END_BLOCK:
+ case WebAssembly::END_BLOCK_S:
if (!ControlFlowStack.empty()) printAnnotation(
OS, "label" + utostr(ControlFlowStack.pop_back_val().first) + ':');
break;
OpenPOWER on IntegriCloud