blob: 486b3b0c4ba9f8a301c95cb4f5869528a39ae045 [file] [log] [blame]
David Brazdil9bc43612015-11-05 21:25:24 +00001# Copyright (C) 2015 The Android Open Source Project
2#
3# Licensed under the Apache License, Version 2.0 (the "License");
4# you may not use this file except in compliance with the License.
5# You may obtain a copy of the License at
6#
7# http://www.apache.org/licenses/LICENSE-2.0
8#
9# Unless required by applicable law or agreed to in writing, software
10# distributed under the License is distributed on an "AS IS" BASIS,
11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12# See the License for the specific language governing permissions and
13# limitations under the License.
14
15.class public LTestCase;
16.super Ljava/lang/Object;
17
18# Test simplification of an empty, dead catch block. Compiler used to segfault
19# because it did expect at least a control-flow instruction (b/25494450).
20
21.method public static testCase_EmptyCatch()I
22 .registers 3
23
24 const v0, 0x0
25 return v0
26
27 :try_start
28 nop
29 :try_end
30 .catchall {:try_start .. :try_end} :catch
31
32 nop
33
34 :catch
35 nop
36
37.end method
38
39# Test simplification of a dead catch block with some code but no control-flow
40# instruction.
41
42.method public static testCase_NoConrolFlowCatch()I
43 .registers 3
44
45 const v0, 0x0
46 return v0
47
48 :try_start
49 nop
50 :try_end
51 .catchall {:try_start .. :try_end} :catch
52
53 nop
54
55 :catch
56 const v1, 0x3
57 add-int v0, v0, v1
58
59.end method
60
61# Test simplification of a dead catch block with normal-predecessors but
62# starting with a move-exception. Verifier does not check trivially dead code
63# and this used to trip a DCHECK (b/25492628).
64
65.method public static testCase_InvalidLoadException()I
66 .registers 3
67
68 const v0, 0x0
69 return v0
70
71 :try_start
72 nop
73 :try_end
74 .catchall {:try_start .. :try_end} :catch
75
76 :catch
77 move-exception v0
78
79.end method
80
81# Test simplification of a live catch block with dead normal-predecessors and
82# starting with a move-exception. Verifier does not check trivially dead code
83# and this used to trip a DCHECK (b/25492628).
84
85.method public static testCase_TriviallyDeadPredecessor(II)I
86 .registers 3
87
88 :try_start
89 div-int v0, p0, p1
90 return v0
91 :try_end
92 .catchall {:try_start .. :try_end} :catch
93
94 # Trivially dead predecessor block.
95 add-int p0, p0, p1
96
97 :catch
98 # This verifies because only exceptional predecessors are live.
99 move-exception v0
100 const v0, 0x0
101 return v0
102
103.end method
104