-
Book Overview & Buying
-
Table Of Contents
Learn LLVM 17 - Second Edition
By :
Two pointers may point to the same memory cell, at which point they 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.
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 pointers, p and q, point to the same memory cell or not. During optimization, an important analysis can be performed called alias analysis. If p and q point to the same memory cell, then they are aliases. Moreover...