Escape Analysis & Capture Tracking in LLVM
Pointer analysis is an important topic in compiler optimization. One interesting aspect is the dynamic scope of pointers. LLVM differentiates between two situations: Pointer Capture: A pointer value is captured if the function makes a copy of any part of the pointer that outlives the call. Pointer Escape: A pointer value escapes if it is accessible from outside the current function or thread. The latter case is sometimes considered separate and called thread-escape. Although the names seem to suggest that these two are opposites, it should be clear from their definition that they are not. Informally, escaping is concerned with the contents of the pointer, while capturing is concerned with the pointer itself[^1]. ...