May-Alias and Must-Alias in Compiler Analysis

Separate possible overlap from guaranteed identity and use each answer only for the transformations it justifies.

Source
Anbloq
Language
English
Created
Updated
Chapters
2
Reading time
1 min
In this article2 chapters
  1. A memory access names a range of bytes
  2. Must facts allow different transformations

A memory access names a range of bytes

Two references can denote the same allocation but touch disjoint subranges. If \(p\) points to the first four bytes of an eight-byte object and \(q\) to the last four, their four-byte accesses do not overlap. If the offset of \(q\) is unknown, a conservative analysis may report possible overlap. A may-alias result means the optimizer must preserve ordering where overlap would matter.

Must facts allow different transformations

Guaranteed identity of a load and a preceding store can justify forwarding the stored value, provided no intervening effect changes it. Proven nonaliasing can permit moving a load past a store. An unknown answer gives neither proof. Language ownership or qualifiers can make alias facts stronger under their documented assumptions. Ownership and borrowing supplies related source-language constraints. Loop hoisting uses alias facts to keep a load’s value stable.[1][2]

References

  1. Andrew C. Myers, Cornell CS 4120: Compiler Course Notes ↩
  2. LLVM Project, LLVM Language Reference Manual ↩