Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
S
swiftshader
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Chen Yisong
swiftshader
Commits
016c56d9
Commit
016c56d9
authored
Jul 23, 2015
by
Andrew Scull
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Handle UINT64_MAX edge case in switch lowering.
BUG= R=jvoung@chromium.org, jvoung Review URL:
https://codereview.chromium.org/1247833003
.
parent
8447bbae
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
36 additions
and
2 deletions
+36
-2
IceSwitchLowering.cpp
src/IceSwitchLowering.cpp
+6
-2
adv-switch-opt.ll
tests_lit/llvm2ice_tests/adv-switch-opt.ll
+30
-0
No files found.
src/IceSwitchLowering.cpp
View file @
016c56d9
...
...
@@ -75,9 +75,13 @@ CaseClusterArray CaseCluster::clusterizeSwitch(Cfg *Func,
// Replace everything with a jump table
InstJumpTable
*
JumpTable
=
InstJumpTable
::
create
(
Func
,
TotalRange
,
Inst
->
getLabelDefault
());
for
(
const
CaseCluster
&
Case
:
CaseClusters
)
for
(
uint64_t
I
=
Case
.
Low
;
I
<=
Case
.
High
;
++
I
)
for
(
const
CaseCluster
&
Case
:
CaseClusters
)
{
// Case.High could be UINT64_MAX which makes the loop awkward. Unwrap the
// last iteration to avoid wrap around problems.
for
(
uint64_t
I
=
Case
.
Low
;
I
<
Case
.
High
;
++
I
)
JumpTable
->
addTarget
(
I
-
MinValue
,
Case
.
Label
);
JumpTable
->
addTarget
(
Case
.
High
-
MinValue
,
Case
.
Label
);
}
CaseClusters
.
clear
();
CaseClusters
.
emplace_back
(
MinValue
,
MaxValue
,
JumpTable
);
...
...
tests_lit/llvm2ice_tests/adv-switch-opt.ll
View file @
016c56d9
...
...
@@ -188,3 +188,33 @@ return:
; CHECK-NEXT: jne
; CHECK-NEXT: cmp {{.*}},0x12
; CHECK-NEXT: je
; Test for correct 64-bit jump table with UINT64_MAX as one of the values.
define
internal
i32
@testJumpTable64
(
i64
%a
)
{
entry:
switch
i64
%a
,
label
%sw.default
[
i64
-6
,
label
%return
i64
-4
,
label
%sw.bb1
i64
-3
,
label
%sw.bb2
i64
-1
,
label
%sw.bb3
]
sw.bb1:
br
label
%return
sw.bb2:
br
label
%return
sw.bb3:
br
label
%return
sw.default:
br
label
%return
return:
%retval.0
=
phi
i32
[
5
,
%sw.default
],
[
4
,
%sw.bb3
],
[
3
,
%sw.bb2
],
[
2
,
%sw.bb1
],
[
1
,
%entry
]
ret
i32
%retval.0
}
; TODO(ascull): this should generate a jump table. For now, just make sure it
; doesn't crash the compiler.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment