A procedure is said to contain aliased values if it can refer to the same memory addresses in two or more distinct ways. A typical example is the following procedure:
Dim g_GlobalVariable As Long...Sub ProcWithAliases(x As Long) x = x + 1 g_GlobalVariable = g_GlobalVariable + 1End Sub
If this procedure is passed the g_GlobalVariable, it is able to modify that variable in two ways, through a direct reference and through the x parameter. Another common variant of aliased values occurs when a procedure expects multiple arguments, and you pass the same variable to two or more of them.
Aliases values are often the effect of poor programming practice, but they are also harmful to optimization. In fact, if you are absolutely sure that your app never makes use of aliased variables, you can turn on the “Assume No Aliasing” advanced compile option. This option informs the compiler that no procedure is able to modify the same memory locations, which enables the compiler to generate more efficient assembly code. More specifically, the compiled program will try to cache the value of those variables into CPU registers, which sensibly speeds up execution.
Summarizing, you don’t have aliased value when: (1) the procedure doesn’t refer to any global variable, (2) if the procedure refers to global variables, you never pass the same variable as a ByRef argument to the procedure, (3) if the procedure expects multiple ByRef arguments, you never pass the same variable in two or more of them.