Generating metadata for type-based alias analysis
Two pointers may point to the same memory cell, and they then alias each other. Memory is not typed in the LLVM model, which makes it difficult for the optimizer to decide if two pointers alias each other or not. If the compiler can prove that two pointers do not alias each other, then more optimizations are possible. In the next section, we will have a closer look at the problem and investigate how adding additional metadata will help, before we implement this approach.
Understanding the need for additional metadata
To demonstrate the problem, let's look at the following function:
void doSomething(int *p, float *q) { *p = 42; *q = 3.1425; }
The optimizer cannot decide if the p
and q
pointers point to the same memory cell or not. During optimization this is an important analysis, called an alias analysis. If p
and q
point to the same memory cell, then they are aliases. If the optimizer can prove...