Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Regression tests for flowgraph construction bug on ExprWhile.
- Loading branch information
Showing
7 changed files
with
444 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,93 @@ | ||
digraph block { | ||
N0[label="entry"]; | ||
N1[label="exit"]; | ||
N2[label="expr 23"]; | ||
N3[label="local mut x"]; | ||
N4[label="expr 23"]; | ||
N5[label="local mut y"]; | ||
N6[label="expr 23"]; | ||
N7[label="local mut z"]; | ||
N8[label="(dummy_node)"]; | ||
N9[label="expr x"]; | ||
N10[label="expr 0"]; | ||
N11[label="expr x > 0"]; | ||
N12[label="expr while x > 0 {\l x -= 1;\l while y > 0 {\l y -= 1;\l while z > 0 { z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l}\l"]; | ||
N13[label="expr 1"]; | ||
N14[label="expr x"]; | ||
N15[label="expr x -= 1"]; | ||
N16[label="(dummy_node)"]; | ||
N17[label="expr y"]; | ||
N18[label="expr 0"]; | ||
N19[label="expr y > 0"]; | ||
N20[label="expr while y > 0 {\l y -= 1;\l while z > 0 { z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l}\l"]; | ||
N21[label="expr 1"]; | ||
N22[label="expr y"]; | ||
N23[label="expr y -= 1"]; | ||
N24[label="(dummy_node)"]; | ||
N25[label="expr z"]; | ||
N26[label="expr 0"]; | ||
N27[label="expr z > 0"]; | ||
N28[label="expr while z > 0 { z -= 1; }"]; | ||
N29[label="expr 1"]; | ||
N30[label="expr z"]; | ||
N31[label="expr z -= 1"]; | ||
N32[label="block { z -= 1; }"]; | ||
N33[label="expr x"]; | ||
N34[label="expr 10"]; | ||
N35[label="expr x > 10"]; | ||
N36[label="expr return"]; | ||
N37[label="(dummy_node)"]; | ||
N38[label="expr \"unreachable\""]; | ||
N39[label="block { return; \"unreachable\"; }"]; | ||
N40[label="expr if x > 10 { return; \"unreachable\"; }"]; | ||
N41[label="block { y -= 1; while z > 0 { z -= 1; } if x > 10 { return; \"unreachable\"; } }"]; | ||
N42[label="block {\l x -= 1;\l while y > 0 {\l y -= 1;\l while z > 0 { z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l}\l"]; | ||
N43[label="block {\l let mut x = 23;\l let mut y = 23;\l let mut z = 23;\l while x > 0 {\l x -= 1;\l while y > 0 {\l y -= 1;\l while z > 0 { z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l }\l}\l"]; | ||
N0 -> N2; | ||
N2 -> N3; | ||
N3 -> N4; | ||
N4 -> N5; | ||
N5 -> N6; | ||
N6 -> N7; | ||
N7 -> N8; | ||
N8 -> N9; | ||
N9 -> N10; | ||
N10 -> N11; | ||
N11 -> N12; | ||
N11 -> N13; | ||
N13 -> N14; | ||
N14 -> N15; | ||
N15 -> N16; | ||
N16 -> N17; | ||
N17 -> N18; | ||
N18 -> N19; | ||
N19 -> N20; | ||
N19 -> N21; | ||
N21 -> N22; | ||
N22 -> N23; | ||
N23 -> N24; | ||
N24 -> N25; | ||
N25 -> N26; | ||
N26 -> N27; | ||
N27 -> N28; | ||
N27 -> N29; | ||
N29 -> N30; | ||
N30 -> N31; | ||
N31 -> N32; | ||
N32 -> N24; | ||
N28 -> N33; | ||
N33 -> N34; | ||
N34 -> N35; | ||
N35 -> N36; | ||
N36 -> N1[label="exiting scope_0 expr while y > 0 {\l y -= 1;\l while z > 0 { z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l}\l,\lexiting scope_1 expr while x > 0 {\l x -= 1;\l while y > 0 {\l y -= 1;\l while z > 0 { z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l}\l"]; | ||
N37 -> N38; | ||
N38 -> N39; | ||
N35 -> N40; | ||
N39 -> N40; | ||
N40 -> N41; | ||
N41 -> N16; | ||
N20 -> N42; | ||
N42 -> N8; | ||
N12 -> N43; | ||
N43 -> N1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#[allow(unreachable_code)] | ||
pub fn expr_while_23() { | ||
let mut x = 23; | ||
let mut y = 23; | ||
let mut z = 23; | ||
|
||
while x > 0 { | ||
x -= 1; | ||
|
||
while y > 0 { | ||
y -= 1; | ||
|
||
while z > 0 { z -= 1; } | ||
|
||
if x > 10 { | ||
return; | ||
"unreachable"; | ||
} | ||
} | ||
} | ||
} |
123 changes: 123 additions & 0 deletions
123
src/test/run-make/graphviz-flowgraph/f24.dot-expected.dot
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,123 @@ | ||
digraph block { | ||
N0[label="entry"]; | ||
N1[label="exit"]; | ||
N2[label="expr 24"]; | ||
N3[label="local mut x"]; | ||
N4[label="expr 24"]; | ||
N5[label="local mut y"]; | ||
N6[label="expr 24"]; | ||
N7[label="local mut z"]; | ||
N8[label="(dummy_node)"]; | ||
N9[label="expr loop {\l if x == 0 { break ; \"unreachable\"; }\l x -= 1;\l loop {\l if y == 0 { break ; \"unreachable\"; }\l y -= 1;\l loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l}\l"]; | ||
N10[label="expr x"]; | ||
N11[label="expr 0"]; | ||
N12[label="expr x == 0"]; | ||
N13[label="expr break"]; | ||
N14[label="(dummy_node)"]; | ||
N15[label="expr \"unreachable\""]; | ||
N16[label="block { break ; \"unreachable\"; }"]; | ||
N17[label="expr if x == 0 { break ; \"unreachable\"; }"]; | ||
N18[label="expr 1"]; | ||
N19[label="expr x"]; | ||
N20[label="expr x -= 1"]; | ||
N21[label="(dummy_node)"]; | ||
N22[label="expr loop {\l if y == 0 { break ; \"unreachable\"; }\l y -= 1;\l loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l}\l"]; | ||
N23[label="expr y"]; | ||
N24[label="expr 0"]; | ||
N25[label="expr y == 0"]; | ||
N26[label="expr break"]; | ||
N27[label="(dummy_node)"]; | ||
N28[label="expr \"unreachable\""]; | ||
N29[label="block { break ; \"unreachable\"; }"]; | ||
N30[label="expr if y == 0 { break ; \"unreachable\"; }"]; | ||
N31[label="expr 1"]; | ||
N32[label="expr y"]; | ||
N33[label="expr y -= 1"]; | ||
N34[label="(dummy_node)"]; | ||
N35[label="expr loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }"]; | ||
N36[label="expr z"]; | ||
N37[label="expr 0"]; | ||
N38[label="expr z == 0"]; | ||
N39[label="expr break"]; | ||
N40[label="(dummy_node)"]; | ||
N41[label="expr \"unreachable\""]; | ||
N42[label="block { break ; \"unreachable\"; }"]; | ||
N43[label="expr if z == 0 { break ; \"unreachable\"; }"]; | ||
N44[label="expr 1"]; | ||
N45[label="expr z"]; | ||
N46[label="expr z -= 1"]; | ||
N47[label="block { if z == 0 { break ; \"unreachable\"; } z -= 1; }"]; | ||
N48[label="expr x"]; | ||
N49[label="expr 10"]; | ||
N50[label="expr x > 10"]; | ||
N51[label="expr return"]; | ||
N52[label="(dummy_node)"]; | ||
N53[label="expr \"unreachable\""]; | ||
N54[label="block { return; \"unreachable\"; }"]; | ||
N55[label="expr if x > 10 { return; \"unreachable\"; }"]; | ||
N56[label="block {\l if y == 0 { break ; \"unreachable\"; }\l y -= 1;\l loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l}\l"]; | ||
N57[label="block {\l if x == 0 { break ; \"unreachable\"; }\l x -= 1;\l loop {\l if y == 0 { break ; \"unreachable\"; }\l y -= 1;\l loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l}\l"]; | ||
N58[label="block {\l let mut x = 24;\l let mut y = 24;\l let mut z = 24;\l loop {\l if x == 0 { break ; \"unreachable\"; }\l x -= 1;\l loop {\l if y == 0 { break ; \"unreachable\"; }\l y -= 1;\l loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l }\l}\l"]; | ||
N0 -> N2; | ||
N2 -> N3; | ||
N3 -> N4; | ||
N4 -> N5; | ||
N5 -> N6; | ||
N6 -> N7; | ||
N7 -> N8; | ||
N8 -> N10; | ||
N10 -> N11; | ||
N11 -> N12; | ||
N12 -> N13; | ||
N13 -> N9[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if x == 0 { break ; \"unreachable\"; },\lexiting scope_4 stmt if x == 0 { break ; \"unreachable\"; },\lexiting scope_5 block {\l if x == 0 { break ; \"unreachable\"; }\l x -= 1;\l loop {\l if y == 0 { break ; \"unreachable\"; }\l y -= 1;\l loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l}\l"]; | ||
N14 -> N15; | ||
N15 -> N16; | ||
N12 -> N17; | ||
N16 -> N17; | ||
N17 -> N18; | ||
N18 -> N19; | ||
N19 -> N20; | ||
N20 -> N21; | ||
N21 -> N23; | ||
N23 -> N24; | ||
N24 -> N25; | ||
N25 -> N26; | ||
N26 -> N22[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if y == 0 { break ; \"unreachable\"; },\lexiting scope_4 stmt if y == 0 { break ; \"unreachable\"; },\lexiting scope_5 block {\l if y == 0 { break ; \"unreachable\"; }\l y -= 1;\l loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l}\l"]; | ||
N27 -> N28; | ||
N28 -> N29; | ||
N25 -> N30; | ||
N29 -> N30; | ||
N30 -> N31; | ||
N31 -> N32; | ||
N32 -> N33; | ||
N33 -> N34; | ||
N34 -> N36; | ||
N36 -> N37; | ||
N37 -> N38; | ||
N38 -> N39; | ||
N39 -> N35[label="exiting scope_0 expr break,\lexiting scope_1 stmt break ;,\lexiting scope_2 block { break ; \"unreachable\"; },\lexiting scope_3 expr if z == 0 { break ; \"unreachable\"; },\lexiting scope_4 stmt if z == 0 { break ; \"unreachable\"; },\lexiting scope_5 block { if z == 0 { break ; \"unreachable\"; } z -= 1; }"]; | ||
N40 -> N41; | ||
N41 -> N42; | ||
N38 -> N43; | ||
N42 -> N43; | ||
N43 -> N44; | ||
N44 -> N45; | ||
N45 -> N46; | ||
N46 -> N47; | ||
N47 -> N34; | ||
N35 -> N48; | ||
N48 -> N49; | ||
N49 -> N50; | ||
N50 -> N51; | ||
N51 -> N1[label="exiting scope_0 expr loop {\l if y == 0 { break ; \"unreachable\"; }\l y -= 1;\l loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l}\l,\lexiting scope_1 expr loop {\l if x == 0 { break ; \"unreachable\"; }\l x -= 1;\l loop {\l if y == 0 { break ; \"unreachable\"; }\l y -= 1;\l loop { if z == 0 { break ; \"unreachable\"; } z -= 1; }\l if x > 10 { return; \"unreachable\"; }\l }\l}\l"]; | ||
N52 -> N53; | ||
N53 -> N54; | ||
N50 -> N55; | ||
N54 -> N55; | ||
N55 -> N56; | ||
N56 -> N21; | ||
N22 -> N57; | ||
N57 -> N8; | ||
N9 -> N58; | ||
N58 -> N1; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
// Copyright 2014 The Rust Project Developers. See the COPYRIGHT | ||
// file at the top-level directory of this distribution and at | ||
// http://rust-lang.org/COPYRIGHT. | ||
// | ||
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||
// option. This file may not be copied, modified, or distributed | ||
// except according to those terms. | ||
|
||
#[allow(unreachable_code)] | ||
pub fn expr_while_24() { | ||
let mut x = 24; | ||
let mut y = 24; | ||
let mut z = 24; | ||
|
||
loop { | ||
if x == 0 { break; "unreachable"; } | ||
x -= 1; | ||
|
||
loop { | ||
if y == 0 { break; "unreachable"; } | ||
y -= 1; | ||
|
||
loop { | ||
if z == 0 { break; "unreachable"; } | ||
z -= 1; | ||
} | ||
|
||
if x > 10 { | ||
return; | ||
"unreachable"; | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.