Assume you are given:
- A list of N (not necessarily distinct) memory ranges of the form [x,y], where x and y are non-negative integers representing the lower and upper bounds of the range, and
- A list of N memory access modes (read or write),
where the $i^{th}$ entry in the memory range list is accessed (either read from or written to) according to the $i^{th}$ entry in the data access modes list.
How do you efficiently generate a data dependency DAG representing the dependencies between subsequent accesses to possibly overlapping memory ranges?
The DAG should not have redundant dependencies. And ideally the algorithm should have running time quadratic in N (or better, if possible).
UPDATE: To clarify, a dependency between two memory accesses exists if
- The two memory ranges being accessed overlap (i.e., have at least one byte in common), and
- At least one of the access modes is a write (concurrent reads from the same memory range are ok).