Summary:
The fundamental design of optimizing compilers has not changed for many decades. It
is oriented around passes, each of which tries to apply a specific transformation. A
celebrated benefit of this design is the separation of concerns, because each
pass is concerned with a single transformation. But what
is subtle is that it also hinders the separation of concerns.
In modern instances of this design,
each pass has at least two responsibilities: performing a transformation and
deciding whether the transformation is profitable. Inevitably, the code dealing with each of these responsibilities
is tightly coupled and one can't interface with or change each piece separately.
However, each of these responsibilities is radically different and the people
having the expertise to improve one do not necessarily have the knowledge
to even understand the other. For instance, profitability
could be picked up by a machine-learning researcher, who is interested in improving the
heuristics used but is not at all interested in learning how the compiler performs
the transformation.
In this thesis, we present a prototype of a transformation,
implemented over the LLVM framework, used to serve a broader goal; that of separating transformations in their own independent, granular APIs. Such APIs should offer high-control and minimal cognitive load to the user, whether this is a compiler expert or not.
The transformation we chose is loop distribution because it is easily comprehensible yet
potentially highly effective, while its implementation is comparable to LLVM's upstream version.
Keywords:
compilers, transformations, API, loop distribution, LLVM