aboutsummaryrefslogtreecommitdiff
path: root/tests/cases
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2014-01-15 17:01:19 -0800
committerAlon Zakai <alonzakai@gmail.com>2014-01-15 17:01:19 -0800
commitc42b937808924f6b922b29d2e0fd1fe1d1b0411c (patch)
tree4027d435b6638a7e72b9519990298fb9314ecc96 /tests/cases
parent8478d6aee54d6c52de16d8c58309534afbf5bf9e (diff)
parente5ccf17e84e7a5102bf9e05ffef01e6672b4c15a (diff)
Merge branch 'incoming'
Diffstat (limited to 'tests/cases')
-rw-r--r--tests/cases/breakinthemiddle2.ll8
-rw-r--r--tests/cases/breakinthemiddle3.ll29
-rw-r--r--tests/cases/gepaddoverflow.ll37
-rw-r--r--tests/cases/gepaddoverflow.txt1
-rw-r--r--tests/cases/invokeundef.ll5
-rw-r--r--tests/cases/switch64_ta2.ll44
-rw-r--r--tests/cases/switch64_ta2.txt2
-rw-r--r--tests/cases/switch64b_ta2.ll54
-rw-r--r--tests/cases/switch64b_ta2.txt3
9 files changed, 122 insertions, 61 deletions
diff --git a/tests/cases/breakinthemiddle2.ll b/tests/cases/breakinthemiddle2.ll
index ba96654f..2f8c1c91 100644
--- a/tests/cases/breakinthemiddle2.ll
+++ b/tests/cases/breakinthemiddle2.ll
@@ -11,10 +11,6 @@ define linkonce_odr i32 @main() align 2 {
label555: ; preds = %0
br label %label569 ; branch should ignore all code after it in the block
; No predecessors!
- %aa472 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
- cleanup
- %aa473 = extractvalue { i8*, i32 } %aa472, 0
- %aa474 = extractvalue { i8*, i32 } %aa472, 1
br label %label569
label569: ; preds = %0
@@ -23,10 +19,6 @@ label569: ; preds = %0
label990:
ret i32 0 ; ret should ignore all code after it in the block
; No predecessors!
- %a472 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
- cleanup
- %a473 = extractvalue { i8*, i32 } %a472, 0
- %a474 = extractvalue { i8*, i32 } %a472, 1
br label %label569
label999: ; preds = %555
diff --git a/tests/cases/breakinthemiddle3.ll b/tests/cases/breakinthemiddle3.ll
deleted file mode 100644
index 38da15ef..00000000
--- a/tests/cases/breakinthemiddle3.ll
+++ /dev/null
@@ -1,29 +0,0 @@
-target datalayout = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-p:32:32:32-v128:32:32"
-target triple = "le32-unknown-nacl"
-
-@.str = private constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1]
-
-define linkonce_odr i32 @main() align 2 {
- %a333 = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
- %z199 = trunc i8 1 to i1 ; [#uses=1]
- switch i32 %a333, label %label999 [
- i32 1000, label %label995
- ] ; switch should ignore all code after it in the block
- ; No predecessors!
- %a472 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
- cleanup
- %a473 = extractvalue { i8*, i32 } %a472, 0
- %a474 = extractvalue { i8*, i32 } %a472, 1
- br label %label999
-
-label995:
- %b333b = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
- br label %label999
-
-label999: ; preds = %555
- ret i32 0
-}
-
-declare i32 @printf(i8*)
-declare i32 @__gxx_personality_v0(...)
-
diff --git a/tests/cases/gepaddoverflow.ll b/tests/cases/gepaddoverflow.ll
new file mode 100644
index 00000000..11246c1d
--- /dev/null
+++ b/tests/cases/gepaddoverflow.ll
@@ -0,0 +1,37 @@
+; ModuleID = 'new.o'
+target datalayout = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-p:32:32:32-v128:32:32"
+target triple = "le32-unknown-nacl"
+
+declare i32 @printf(i8* noalias, ...) nounwind
+
+@x = common global [4194304 x i8] zeroinitializer, align 4
+@.str = private constant [6 x i8] c"*%d*\0A\00", align 1
+
+define i8* @test_gep(i32 %y) nounwind readnone {
+ ; JavaScript uses double precision 64-bit floating point values, with
+ ; a 53 bit mantissa. The maximum precisely representable integer is
+ ; 9007199254740992. A number close to that limit is constructed here
+ ; for the constant part of the getelementptr instruction:
+ ; 4194304 * 2147483647 == 9007199250546688 == 9007199254740992 - 4194304
+ ; If that number appears in JavaScript source instead of being properly
+ ; limited to 32 bits, the %y parameter can be used to exceed the maximum
+ ; precisely representable integer, and make the computation inexact.
+ %test_res = getelementptr [4194304 x i8]* @x, i32 2147483647, i32 %y
+ ret i8* %test_res
+}
+
+define i32 @main() {
+ %res_0 = call i8* (i32)* @test_gep(i32 1000000000)
+ %res_1 = call i8* (i32)* @test_gep(i32 1000000001)
+ %res_0_i = ptrtoint i8* %res_0 to i32
+ %res_1_i = ptrtoint i8* %res_1 to i32
+
+ ; If getelementptr limited the constant part of the offset to 32 bits,
+ ; result will be 1. Otherwise, it cannot be 1 because the large numbers in
+ ; the calculation cannot be accurately represented by floating point math.
+ %res_diff = sub i32 %res_1_i, %res_0_i
+ %printf_res = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([6 x i8]* @.str, i32 0, i32 0), i32 %res_diff)
+
+ ret i32 0
+}
+
diff --git a/tests/cases/gepaddoverflow.txt b/tests/cases/gepaddoverflow.txt
new file mode 100644
index 00000000..10fd998b
--- /dev/null
+++ b/tests/cases/gepaddoverflow.txt
@@ -0,0 +1 @@
+*1*
diff --git a/tests/cases/invokeundef.ll b/tests/cases/invokeundef.ll
index be1dd671..2f13e7ab 100644
--- a/tests/cases/invokeundef.ll
+++ b/tests/cases/invokeundef.ll
@@ -31,6 +31,8 @@ invcont33:
ret i32 %retval1
lpad106:
+ %Z = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
+ cleanup
ret i32 %retval1
return: ; preds = %entry
@@ -40,3 +42,6 @@ return: ; preds = %entry
; [#uses=1]
declare i32 @puts(i8*)
+
+declare i32 @__gxx_personality_v0(...)
+
diff --git a/tests/cases/switch64_ta2.ll b/tests/cases/switch64_ta2.ll
index 4d5c6273..1a6d52f3 100644
--- a/tests/cases/switch64_ta2.ll
+++ b/tests/cases/switch64_ta2.ll
@@ -1,12 +1,14 @@
target datalayout = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-p:32:32:32-v128:32:32"
target triple = "le32-unknown-nacl"
-@.str = private constant [15 x i8] c"hello, world!\0A\00", align 1 ; [#uses=1]
+@.str = private constant [18 x i8] c"hello, world: %d\0A\00", align 1
+
+declare i32 @printf(i8*, ...)
define linkonce_odr i32 @main() align 2 {
- %a333 = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
- %a444 = zext i32 %a333 to i64
- %a199 = trunc i8 1 to i1 ; [#uses=1]
+ %a333 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0), i32 5)
+ %a400 = zext i32 %a333 to i64
+ %a444 = udiv i64 %a400, 3
switch i64 %a444, label %label999 [
i64 1000, label %label9950
i64 1001, label %label9951
@@ -18,41 +20,35 @@ define linkonce_odr i32 @main() align 2 {
i64 1007, label %label9957
i64 1008, label %label9958
i64 1009, label %label9959
- ] ; switch should ignore all code after it in the block
- ; No predecessors!
- %a472 = landingpad { i8*, i32 } personality i8* bitcast (i32 (...)* @__gxx_personality_v0 to i8*)
- cleanup
- %a473 = extractvalue { i8*, i32 } %a472, 0
- %a474 = extractvalue { i8*, i32 } %a472, 1
- br label %label999
+ ]
label9950:
- %a333b = call i32 @printf(i8* getelementptr inbounds ([15 x i8]* @.str, i32 0, i32 0)) ; [#uses=0]
+ %waka = phi i32 [1000, %0], [0, %label9951], [1, %label9952], [2, %label9953], [3, %label9954], [4, %label9955], [5, %label9956], [6, %label9957], [7, %label9958], [8, %label9959]
+ %a333b = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0), i32 %waka)
br label %label999
label9951:
- br label %label999
+ br label %label9950
label9952:
- br label %label999
+ br label %label9950
label9953:
- br label %label999
+ br label %label9950
label9954:
- br label %label999
+ br label %label9950
label9955:
- br label %label999
+ br label %label9950
label9956:
- br label %label999
+ br label %label9950
label9957:
- br label %label999
+ br label %label9950
label9958:
- br label %label999
+ br label %label9950
label9959:
- br label %label999
+ br label %label9950
label999: ; preds = %555
+ %last = phi i32 [1, %0], [2, %label9950]
+ %a333c = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0), i32 %last)
ret i32 0
}
-declare i32 @printf(i8*)
-declare i32 @__gxx_personality_v0(...)
-
diff --git a/tests/cases/switch64_ta2.txt b/tests/cases/switch64_ta2.txt
new file mode 100644
index 00000000..72084b0c
--- /dev/null
+++ b/tests/cases/switch64_ta2.txt
@@ -0,0 +1,2 @@
+hello, world: 5
+hello, world: 1
diff --git a/tests/cases/switch64b_ta2.ll b/tests/cases/switch64b_ta2.ll
new file mode 100644
index 00000000..4364725f
--- /dev/null
+++ b/tests/cases/switch64b_ta2.ll
@@ -0,0 +1,54 @@
+target datalayout = "e-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-p:32:32:32-v128:32:32"
+target triple = "le32-unknown-nacl"
+
+@.str = private constant [18 x i8] c"hello, world: %d\0A\00", align 1
+
+declare i32 @printf(i8*, ...)
+
+define linkonce_odr i32 @main() align 2 {
+ %a333 = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0), i32 5)
+ %a400 = zext i32 %a333 to i64
+ %a444 = udiv i64 %a400, 3
+ switch i64 %a444, label %label999 [
+ i64 0, label %label9950
+ i64 1, label %label9951
+ i64 2, label %label9952
+ i64 3, label %label9953
+ i64 4, label %label9954
+ i64 5, label %label9955
+ i64 6, label %label9956
+ i64 7, label %label9957
+ i64 8, label %label9958
+ i64 9, label %label9959
+ ]
+
+label9950:
+ %waka = phi i32 [11000, %0], [10, %label9951], [11, %label9952], [12, %label9953], [13, %label9954], [14, %label9955], [15, %label9956], [16, %label9957], [17, %label9958], [18, %label9959]
+ %a333b = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0), i32 %waka)
+ br label %label999
+
+label9951:
+ br label %label9950
+label9952:
+ br label %label9950
+label9953:
+ br label %label9950
+label9954:
+ br label %label9950
+label9955:
+ br label %label9950
+label9956:
+ br label %label9950
+label9957:
+ br label %label9950
+label9958:
+ br label %label9950
+label9959:
+ br label %label9950
+
+label999: ; preds = %555
+ %last = phi i32 [1, %0], [2, %label9950]
+ %a333c = call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([18 x i8]* @.str, i32 0, i32 0), i32 %last)
+ ret i32 0
+}
+
diff --git a/tests/cases/switch64b_ta2.txt b/tests/cases/switch64b_ta2.txt
new file mode 100644
index 00000000..917d42e5
--- /dev/null
+++ b/tests/cases/switch64b_ta2.txt
@@ -0,0 +1,3 @@
+hello, world: 5
+hello, world: 14
+hello, world: 2