Nadav Rotem
d78b376d07
[passes] Replace the old invalidation lattice with a new invalidation scheme.
...
The old invalidation lattice was incorrect because changes to control flow could cause changes to the
call graph, so we've decided to change the way passes invalidate analysis. In the new scheme, the lattice
is replaced with a list of traits that passes preserve or invalidate. The current traits are Calls and Branches.
Now, passes report which traits they preserve, which is the opposite of the previous implementation where
passes needed to report what they invalidate.
Node: I tried to limit the changes in this commit to mechanical changes to ease the review. I will cleanup some
of the code in a following commit.
Swift SVN r26449
2015-03-23 21:18:58 +00:00
Nadav Rotem
550de8df2e
[overflow] eliminate subtraction based on equality constraints.
...
Swift SVN r26192
2015-03-16 22:12:29 +00:00
Nadav Rotem
ced25883a0
[overflow] Fix a bug in the comparison of literals of with different bitwidths
...
Swift SVN r26060
2015-03-12 20:36:53 +00:00
Nadav Rotem
f3daf61fdd
Wrap the line to 80 col.
...
Swift SVN r26053
2015-03-12 19:00:45 +00:00
Nadav Rotem
1336b53a08
Bugfix. When scanning the basic block in reverse skip the 'end' because it is not a valid instruction.
...
Swift SVN r26042
2015-03-12 08:11:25 +00:00
Nadav Rotem
063ebee83a
Fix a typo
...
Swift SVN r26039
2015-03-12 07:27:44 +00:00
Nadav Rotem
95278e774e
[overflow] Scan the code in reverse and allow future (stronger) overflow checks to replace early overflow checks.
...
func reverse(x : Int) {
x + 1 // remove
x + 2 // remove
x + 3 // remove
x + 4 // remove
x + 5 // keep
}
Swift SVN r26038
2015-03-12 07:18:53 +00:00
Nadav Rotem
15ba646870
[overflow] Refactor the code that removes the dead cond_fail instructions. NFC.
...
Swift SVN r26037
2015-03-12 07:18:52 +00:00
Nadav Rotem
8572586415
[overflow] Rename a method and document it.
...
Swift SVN r26036
2015-03-12 07:18:50 +00:00
Nadav Rotem
3dd40e5c42
Add a label to the llvm_unreachable. The build fails on some configurations without one.
...
Swift SVN r26019
2015-03-12 01:11:59 +00:00
Nadav Rotem
98a35d5ffc
[overflow] Remove signed and unsigned overflow checks for X+1 and X-1 if X is smaller/greater than some other number.
...
If X is known to be smaller than some other number then we can add a 1 to X.
If X is known to be grater than some other number then we can subtract 1 from X.
func add1_signed_branch(x : Int, y : Int) {
if (x < y) {
sink(x + 1) // remove
sink(x + 2) // keep
}
}
Swift SVN r26016
2015-03-12 00:55:20 +00:00
Nadav Rotem
099d5d4cd2
[overflow] Remove signed and unsinged overflow checks on addition of a stronger check was executed before the current one.
...
func unsigned_add_previous_traps(x : UInt) {
sink(x + 9) // keep (this is the first overflow check)
sink(x + 2) // remove
sink(x + 3) // remove
sink(x + 5) // remove
sink(x + 10) // keep (this check is not guarded by the first check)
sink(x + 5) // remove
}
Swift SVN r26015
2015-03-12 00:55:18 +00:00
Nadav Rotem
15aa317302
[overflow] Remove signed and unsigned overflow checks if we executed a stronger trap before the current one.
...
func foo(x : Int) {
sink(x - 9) // keep (this is the first overflow check)
sink(x - 2) // remove
sink(x - 3) // remove
sink(x - 5) // remove
sink(x - 10) // keep (not guarded by the first overflow check)
sink(x - 5) // remove
}
Swift SVN r26013
2015-03-12 00:55:17 +00:00
Nadav Rotem
bf3047a292
[overflow] Also optimize *unsigned* sub that are guarded by branches.
...
Swift SVN r26012
2015-03-12 00:55:16 +00:00
Nadav Rotem
6274423a77
[overflow] Add code to remove signed sub overflow checks under a branch:
...
func sub_signed_branch_cond(x : Int) {
if (x < 2) {
return
}
sink(x - 1) // remove
sink(x - 2) // remove
sink(x - 3) // keep
}
func sub_signed_branch_cond2(x : Int) {
if (x >= 2) {
sink(x - 1) // remove
sink(x - 2) // remove
sink(x - 3) // keep
}
}
Swift SVN r26011
2015-03-12 00:55:15 +00:00
Nadav Rotem
c0124c0b42
[overflow] Scan the Constraint list and try to remove the condfail.
...
Swift SVN r26010
2015-03-12 00:55:13 +00:00
Nadav Rotem
8ecf1511a3
[overflow] Add helper functions to evaluate the numeric relations between sil values.
...
Swift SVN r26009
2015-03-12 00:55:12 +00:00
Nadav Rotem
cdfac4bfee
[overflow] Scan the function body and collect overflow constraints.
...
Swift SVN r26008
2015-03-12 00:55:12 +00:00
Nadav Rotem
069f8eaafa
[overflow] Add a new struct: Constraint - to represent a range constraint in a part of the function.
...
Swift SVN r26007
2015-03-12 00:55:11 +00:00
Nadav Rotem
5d08db87ec
[overflow checks] Add a new (empty) pass to remove overflow checks
...
Swift SVN r26006
2015-03-12 00:55:06 +00:00