aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2011-11-14 00:00:35 +0000
committerChandler Carruth <chandlerc@gmail.com>2011-11-14 00:00:35 +0000
commitb5856c83ff4fd796c3eabccca2ed3b06173aeb51 (patch)
tree7812a1e4c458d3b3c2918435cb7b1f2b1f6c9cdd /test
parent6c9cc21d85cdef79b971f710ace287f3a2f847a3 (diff)
downloadexternal_llvm-b5856c83ff4fd796c3eabccca2ed3b06173aeb51.zip
external_llvm-b5856c83ff4fd796c3eabccca2ed3b06173aeb51.tar.gz
external_llvm-b5856c83ff4fd796c3eabccca2ed3b06173aeb51.tar.bz2
Teach machine block placement to cope with unnatural loops. These don't
get loop info structures associated with them, and so we need some way to make forward progress selecting and placing basic blocks. The technique used here is pretty brutal -- it just scans the list of blocks looking for the first unplaced candidate. It keeps placing blocks like this until the CFG becomes tractable. The cost is somewhat unfortunate, it requires allocating a vector of all basic block pointers eagerly. I have some ideas about how to simplify and optimize this, but I'm trying to get the logic correct first. Thanks to Benjamin Kramer for the reduced test case out of GCC. Sadly there are other bugs that GCC is tickling that I'm reducing and working on now. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@144516 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/CodeGen/X86/block-placement.ll37
1 files changed, 37 insertions, 0 deletions
diff --git a/test/CodeGen/X86/block-placement.ll b/test/CodeGen/X86/block-placement.ll
index 4f0b671..fed27c6 100644
--- a/test/CodeGen/X86/block-placement.ll
+++ b/test/CodeGen/X86/block-placement.ll
@@ -234,3 +234,40 @@ loop.body.2:
exit:
ret i32 %sum
}
+
+define void @unnatural_cfg1() {
+; Test that we can handle a loop with an inner unnatural loop at the end of
+; a function. This is a gross CFG reduced out of the single source GCC.
+; CHECK: unnatural_cfg1
+; CHECK: %entry
+; CHECK: %loop.body1
+; CHECK: %loop.body3
+; CHECK: %loop.body2
+
+entry:
+ br label %loop.header
+
+loop.header:
+ br label %loop.body1
+
+loop.body1:
+ br i1 undef, label %loop.body3, label %loop.body2
+
+loop.body2:
+ %ptr = load i32** undef, align 4
+ br label %loop.body3
+
+loop.body3:
+ %myptr = phi i32* [ %ptr2, %loop.body5 ], [ %ptr, %loop.body2 ], [ undef, %loop.body1 ]
+ %bcmyptr = bitcast i32* %myptr to i32*
+ %val = load i32* %bcmyptr, align 4
+ %comp = icmp eq i32 %val, 48
+ br i1 %comp, label %loop.body4, label %loop.body5
+
+loop.body4:
+ br i1 undef, label %loop.header, label %loop.body5
+
+loop.body5:
+ %ptr2 = load i32** undef, align 4
+ br label %loop.body3
+}