[cfe-commits] r100235 - in /cfe/trunk/test/CodeGen: rdr-6098585-default-after-caserange.c rdr-6098585-default-fallthrough-to-caserange.c rdr-6098585-empty-case-range.c rdr-6098585-fallthrough-to-empty-range.c rdr-6098585-unsigned-caserange.c switch.c
Daniel Dunbar
daniel at zuster.org
Fri Apr 2 15:29:35 PDT 2010
Author: ddunbar
Date: Fri Apr 2 17:29:35 2010
New Revision: 100235
URL: http://llvm.org/viewvc/llvm-project?rev=100235&view=rev
Log:
Merge several tests into switch.c.
Removed:
cfe/trunk/test/CodeGen/rdr-6098585-default-after-caserange.c
cfe/trunk/test/CodeGen/rdr-6098585-default-fallthrough-to-caserange.c
cfe/trunk/test/CodeGen/rdr-6098585-empty-case-range.c
cfe/trunk/test/CodeGen/rdr-6098585-fallthrough-to-empty-range.c
cfe/trunk/test/CodeGen/rdr-6098585-unsigned-caserange.c
Modified:
cfe/trunk/test/CodeGen/switch.c
Removed: cfe/trunk/test/CodeGen/rdr-6098585-default-after-caserange.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/rdr-6098585-default-after-caserange.c?rev=100234&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/rdr-6098585-default-after-caserange.c (original)
+++ cfe/trunk/test/CodeGen/rdr-6098585-default-after-caserange.c (removed)
@@ -1,18 +0,0 @@
-// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm-bc -o - %s | opt -std-compile-opts | llvm-dis > %t
-// RUN: grep "ret i32" %t | count 1
-// RUN: grep "ret i32 10" %t | count 1
-
-// Ensure that default after a case range is not ignored.
-
-static int f1(unsigned x) {
- switch(x) {
- case 10 ... 0xFFFFFFFF:
- return 0;
- default:
- return 10;
- }
-}
-
-int g() {
- return f1(2);
-}
Removed: cfe/trunk/test/CodeGen/rdr-6098585-default-fallthrough-to-caserange.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/rdr-6098585-default-fallthrough-to-caserange.c?rev=100234&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/rdr-6098585-default-fallthrough-to-caserange.c (original)
+++ cfe/trunk/test/CodeGen/rdr-6098585-default-fallthrough-to-caserange.c (removed)
@@ -1,20 +0,0 @@
-// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm-bc -o - %s | opt -std-compile-opts | llvm-dis > %t
-// RUN: grep "ret i32 10" %t
-
-// Ensure that this doesn't compile to infinite loop in g() due to
-// miscompilation of fallthrough from default to a (tested) case
-// range.
-
-static int f0(unsigned x) {
- switch(x) {
- default:
- x += 1;
- case 10 ... 0xFFFFFFFF:
- return 0;
- }
-}
-
-int g() {
- f0(1);
- return 10;
-}
Removed: cfe/trunk/test/CodeGen/rdr-6098585-empty-case-range.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/rdr-6098585-empty-case-range.c?rev=100234&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/rdr-6098585-empty-case-range.c (original)
+++ cfe/trunk/test/CodeGen/rdr-6098585-empty-case-range.c (removed)
@@ -1,23 +0,0 @@
-// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm-bc -o - %s | opt -std-compile-opts | llvm-dis > %t
-// RUN: grep "ret i32" %t | count 2
-// RUN: grep "ret i32 3" %t | count 2
-
-// This generated incorrect code because of poor switch chaining.
-int f1(int x) {
- switch(x) {
- default:
- return 3;
- case 10 ... 0xFFFFFFFF:
- return 0;
- }
-}
-
-// This just asserted because of the way case ranges were calculated.
-int f2(int x) {
- switch (x) {
- default:
- return 3;
- case 10 ... -1:
- return 0;
- }
-}
Removed: cfe/trunk/test/CodeGen/rdr-6098585-fallthrough-to-empty-range.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/rdr-6098585-fallthrough-to-empty-range.c?rev=100234&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/rdr-6098585-fallthrough-to-empty-range.c (original)
+++ cfe/trunk/test/CodeGen/rdr-6098585-fallthrough-to-empty-range.c (removed)
@@ -1,15 +0,0 @@
-// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm-bc -o - %s | opt -std-compile-opts | llvm-dis > %t
-// RUN: grep "ret i32 %" %t
-
-// Make sure return is not constant (if empty range is skipped or miscompiled)
-
-int f0(unsigned x) {
- switch(x) {
- case 2:
- // fallthrough empty range
- case 10 ... 9:
- return 10;
- default:
- return 0;
- }
-}
Removed: cfe/trunk/test/CodeGen/rdr-6098585-unsigned-caserange.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/rdr-6098585-unsigned-caserange.c?rev=100234&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/rdr-6098585-unsigned-caserange.c (original)
+++ cfe/trunk/test/CodeGen/rdr-6098585-unsigned-caserange.c (removed)
@@ -1,12 +0,0 @@
-// RUN: %clang_cc1 -triple i386-unknown-unknown -emit-llvm-bc -o - %s | opt -std-compile-opts | llvm-dis > %t
-// RUN: grep "ret i32" %t | count 1
-// RUN: grep "ret i32 3" %t | count 1
-
-int f2(unsigned x) {
- switch(x) {
- default:
- return 3;
- case 0xFFFFFFFF ... 1: // This range should be empty because x is unsigned.
- return 0;
- }
-}
Modified: cfe/trunk/test/CodeGen/switch.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/switch.c?rev=100235&r1=100234&r2=100235&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/switch.c (original)
+++ cfe/trunk/test/CodeGen/switch.c Fri Apr 2 17:29:35 2010
@@ -100,3 +100,97 @@
}
}
+
+// CHECK: define i32 @f8(
+// CHECK: ret i32 3
+// CHECK: }
+int f8(unsigned x) {
+ switch(x) {
+ default:
+ return 3;
+ case 0xFFFFFFFF ... 1: // This range should be empty because x is unsigned.
+ return 0;
+ }
+}
+
+// Ensure that default after a case range is not ignored.
+//
+// CHECK: define i32 @f9()
+// CHECK: ret i32 10
+// CHECK: }
+static int f9_0(unsigned x) {
+ switch(x) {
+ case 10 ... 0xFFFFFFFF:
+ return 0;
+ default:
+ return 10;
+ }
+}
+int f9() {
+ return f9_0(2);
+}
+
+// Ensure that this doesn't compile to infinite loop in g() due to
+// miscompilation of fallthrough from default to a (tested) case
+// range.
+//
+// CHECK: define i32 @f10()
+// CHECK: ret i32 10
+// CHECK: }
+static int f10_0(unsigned x) {
+ switch(x) {
+ default:
+ x += 1;
+ case 10 ... 0xFFFFFFFF:
+ return 0;
+ }
+}
+
+int f10() {
+ f10_0(1);
+ return 10;
+}
+
+// This generated incorrect code because of poor switch chaining.
+//
+// CHECK: define i32 @f11(
+// CHECK: ret i32 3
+// CHECK: }
+int f11(int x) {
+ switch(x) {
+ default:
+ return 3;
+ case 10 ... 0xFFFFFFFF:
+ return 0;
+ }
+}
+
+// This just asserted because of the way case ranges were calculated.
+//
+// CHECK: define i32 @f12(
+// CHECK: ret i32 3
+// CHECK: }
+int f12(int x) {
+ switch (x) {
+ default:
+ return 3;
+ case 10 ... -1:
+ return 0;
+ }
+}
+
+// Make sure return is not constant (if empty range is skipped or miscompiled)
+//
+// CHECK: define i32 @f13(
+// CHECK: ret i32 %
+// CHECK: }
+int f13(unsigned x) {
+ switch(x) {
+ case 2:
+ // fallthrough empty range
+ case 10 ... 9:
+ return 10;
+ default:
+ return 0;
+ }
+}
More information about the cfe-commits
mailing list