| | 1 | = Alias Analysis = |
| | 2 | |
| | 3 | Goal: help POR to be more precise |
| | 4 | |
| | 5 | == Examples == |
| | 6 | |
| | 7 | Let `s` be a statement, and `p` be a pointer, let `O(p, s)` be the set of objects that `p` may alias to at the location where `s` may be enabled. Note that each statement has a unique source location. |
| | 8 | Let a state `S` be a tuple `(p0: s0, p1: s1, ...)`, which contains the statement that maybe enabled for each process. For simplicity, we ignore the value of variables here and assume that the execution of each process is always deterministic. |
| | 9 | |
| | 10 | === Example 1 === |
| | 11 | |
| | 12 | {{{ |
| | 13 | int x=0, y=0; |
| | 14 | |
| | 15 | void f(int *q) { |
| | 16 | *q = 1; //s1: would like to know p!=q here |
| | 17 | } |
| | 18 | |
| | 19 | int main() { |
| | 20 | int *p = &x; |
| | 21 | |
| | 22 | $proc p1 = $spawn f(&y); |
| | 23 | *p = 99; //s0: would like to know p!=q here |
| | 24 | $wait(p1); |
| | 25 | } |
| | 26 | }}} |
| | 27 | |
| | 28 | Suppose `p0` is the process executes the main function, and `p1` is the spawned process that executes `f`. |
| | 29 | |
| | 30 | Then the alias result of statements `s0` and `s1` would be: |
| | 31 | |
| | 32 | `O(p, s0)={x}` |
| | 33 | `O(q, s1)={y}` |
| | 34 | |
| | 35 | Suppose the current state is `S=(p0: s0, p1:s1)`, i.e., the enable statement of `p0` and `p1` is `s0` and `s1`, respectively. Since we know *statically* that `O(p, s0)` never intersect with `O(q, s1)`, then we know that `s0` and `s1` commute. So the ample set at `S` is either `{p0}` or `{p1}`. |
| | 36 | |
| | 37 | |
| | 38 | |
| | 39 | |
| | 40 | |