forked from facebook/hermes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
switch_dup.js
64 lines (62 loc) · 1.86 KB
/
switch_dup.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
// Copyright (c) Facebook, Inc. and its affiliates.
//
// This source code is licensed under the MIT license found in the LICENSE
// file in the root directory of this source tree.
//
// RUN: %hermes -dump-ir %s | %FileCheck --match-full-lines %s
function foo1(x) {
switch (x) {
case 10: return 1;
case 10: return 2;
case 11: return 3;
}
}
//CHECK-LABEL: function foo1(x)
//CHECK-NEXT: frame = [x]
//CHECK-NEXT: %BB0:
//CHECK-NEXT: %0 = StoreFrameInst %x, [x]
//CHECK-NEXT: %1 = LoadFrameInst [x]
//CHECK-NEXT: %2 = SwitchInst %1, %BB1, 10 : number, %BB2, 11 : number, %BB3
//CHECK-NEXT: %BB1:
//CHECK-NEXT: %3 = ReturnInst undefined : undefined
//CHECK-NEXT: %BB2:
//CHECK-NEXT: %4 = ReturnInst 1 : number
//CHECK-NEXT: %BB4:
//CHECK-NEXT: %5 = BranchInst %BB5
//CHECK-NEXT: %BB5:
//CHECK-NEXT: %6 = ReturnInst 2 : number
//CHECK-NEXT: %BB6:
//CHECK-NEXT: %7 = BranchInst %BB3
//CHECK-NEXT: %BB3:
//CHECK-NEXT: %8 = ReturnInst 3 : number
//CHECK-NEXT: %BB7:
//CHECK-NEXT: %9 = BranchInst %BB1
//CHECK-NEXT: function_end
function foo2(x) {
switch (x) {
case 10: return 1;
case "10": return 2;
case "10": return 3;
}
}
//CHECK-LABEL: function foo2(x)
//CHECK-NEXT: frame = [x]
//CHECK-NEXT: %BB0:
//CHECK-NEXT: %0 = StoreFrameInst %x, [x]
//CHECK-NEXT: %1 = LoadFrameInst [x]
//CHECK-NEXT: %2 = SwitchInst %1, %BB1, 10 : number, %BB2, "10" : string, %BB3
//CHECK-NEXT: %BB1:
//CHECK-NEXT: %3 = ReturnInst undefined : undefined
//CHECK-NEXT: %BB2:
//CHECK-NEXT: %4 = ReturnInst 1 : number
//CHECK-NEXT: %BB4:
//CHECK-NEXT: %5 = BranchInst %BB3
//CHECK-NEXT: %BB3:
//CHECK-NEXT: %6 = ReturnInst 2 : number
//CHECK-NEXT: %BB5:
//CHECK-NEXT: %7 = BranchInst %BB6
//CHECK-NEXT: %BB6:
//CHECK-NEXT: %8 = ReturnInst 3 : number
//CHECK-NEXT: %BB7:
//CHECK-NEXT: %9 = BranchInst %BB1
//CHECK-NEXT: function_end