summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
diff options
context:
space:
mode:
authorDan Gohman <dan433584@gmail.com>2016-02-12 21:19:25 +0000
committerDan Gohman <dan433584@gmail.com>2016-02-12 21:19:25 +0000
commita187ab2aeb4666d799a24b6c9472e6e67d640e1f (patch)
tree045e170fda28d86b70c69303e5801ab63c38daaa /llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
parentf1d598c2f65cf8d3ca3cb379c6c72023cd35f5a3 (diff)
downloadbcm5719-llvm-a187ab2aeb4666d799a24b6c9472e6e67d640e1f.tar.gz
bcm5719-llvm-a187ab2aeb4666d799a24b6c9472e6e67d640e1f.zip
[WebAssembly] Fix insertion of a BLOCK in a loop header that also ends a BLOCK.
llvm-svn: 260737
Diffstat (limited to 'llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp')
-rw-r--r--llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp4
1 files changed, 3 insertions, 1 deletions
diff --git a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
index 9b987650d2f..7581687a7d6 100644
--- a/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
+++ b/llvm/lib/Target/WebAssembly/WebAssemblyCFGStackify.cpp
@@ -334,8 +334,10 @@ static void PlaceBlockMarker(MachineBasicBlock &MBB, MachineFunction &MF,
MachineLoop *HeaderLoop = MLI.getLoopFor(Header);
if (HeaderLoop && MBB.getNumber() > LoopBottom(HeaderLoop)->getNumber()) {
// Header is the header of a loop that does not lexically contain MBB, so
- // the BLOCK needs to be above the LOOP.
+ // the BLOCK needs to be above the LOOP, after any END constructs.
InsertPos = Header->begin();
+ while (InsertPos->getOpcode() != WebAssembly::LOOP)
+ ++InsertPos;
} else {
// Otherwise, insert the BLOCK as late in Header as we can, but before the
// beginning of the local expression tree and any nested BLOCKs.
OpenPOWER on IntegriCloud