Convert the CFG traversal tests to file tests.

Add a "cfg_postorder:" printout to the "test domtree" file tests and use
that to check the computed CFG post-order instead of doing it manually
with Rust code.
This commit is contained in:
Jakob Stoklund Olesen
2017-12-08 13:54:19 -08:00
parent a7eb13a151
commit 7d5f2f0404
10 changed files with 125 additions and 240 deletions

View File

@@ -3,7 +3,7 @@ test print-cfg
test verifier
function %nonsense(i32, i32) -> f32 {
; check: digraph %nonsense {
; check: digraph "%nonsense" {
; regex: I=\binst\d+\b
; check: label="{ebb0 | <$(BRZ=$I)>brz ebb2 | <$(JUMP=$I)>jump ebb1}"]

View File

@@ -4,7 +4,7 @@ test print-cfg
test verifier
function %nonsense(i32) {
; check: digraph %nonsense {
; check: digraph "%nonsense" {
ebb0(v1: i32):
trap user0 ; error: terminator instruction was encountered before the end

View File

@@ -2,7 +2,7 @@
test print-cfg
function %not_reached(i32) -> i32 {
; check: digraph %not_reached {
; check: digraph "%not_reached" {
; check: ebb0 [shape=record, label="{ebb0 | <inst0>brnz ebb2}"]
; check: ebb1 [shape=record, label="{ebb1 | <inst4>jump ebb0}"]
; check: ebb2 [shape=record, label="{ebb2}"]

View File

@@ -11,3 +11,8 @@ function %test(i32) {
ebb3:
return
}
; check: cfg_postorder:
; sameln: ebb2
; sameln: ebb3
; sameln: ebb1
; sameln: ebb0

View File

@@ -18,3 +18,67 @@ function %test(i32) {
brz v0, ebb4
return
}
; Fall-through-first, prune-at-source DFT:
;
; ebb0 {
; ebb0:brz v0, ebb1 {
; ebb0:jump ebb2 {
; ebb2 {
; ebb2:brz v2, ebb2 -
; ebb2:brz v3, ebb1 -
; ebb2:brz v4, ebb4 {
; ebb2: jump ebb5 {
; ebb5 {}
; }
; ebb4 {}
; }
; } ebb2
; }
; ebb1 {
; ebb1:jump ebb3 {
; ebb3 {}
; }
; } ebb1
; }
; } ebb0
;
; check: cfg_postorder:
; sameln: ebb5
; sameln: ebb3
; sameln: ebb4
; sameln: ebb2
; sameln: ebb1
; sameln: ebb0
function %loop2(i32) native {
ebb0(v0: i32):
brz v0, ebb1 ; dominates: ebb1 ebb3 ebb4 ebb5
jump ebb2 ; dominates: ebb2
ebb1:
jump ebb3
ebb2:
brz v0, ebb4
jump ebb5
ebb3:
jump ebb4
ebb4:
brz v0, ebb3
brnz v0, ebb5
jump ebb6 ; dominates: ebb6
ebb5:
brz v0, ebb4
trap user0
ebb6:
jump ebb7 ; dominates: ebb7
ebb7:
return
}
; check: cfg_postorder:
; sameln: ebb5
; sameln: ebb7
; sameln: ebb6
; sameln: ebb3
; sameln: ebb4
; sameln: ebb2
; sameln: ebb1
; sameln: ebb0

View File

@@ -29,3 +29,29 @@ function %test(i32) {
ebb9:
return
}
function %test(i32) native {
ebb0(v0: i32):
brz v0, ebb1 ; dominates: ebb1 ebb3 ebb4 ebb5
jump ebb2 ; dominates: ebb2
ebb1:
jump ebb3
ebb2:
brz v0, ebb4
jump ebb5
ebb3:
jump ebb4
ebb4:
brz v0, ebb3
jump ebb5
ebb5:
brz v0, ebb4
return
}
; check: cfg_postorder:
; sameln: ebb5
; sameln: ebb3
; sameln: ebb4
; sameln: ebb2
; sameln: ebb1
; sameln: ebb0