The “Assume No Aliasing” compiler option

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.

Share the Post:
Share on facebook
Share on twitter
Share on linkedin

Overview

The Latest

microsoft careers

Top Careers at Microsoft

Microsoft has gained its position as one of the top companies in the world, and Microsoft careers are flourishing. This multinational company is efficiently developing popular software and computers with other consumer electronics. It is a dream come true for so many people to acquire a high paid, high-prestige job

your company's audio

4 Areas of Your Company Where Your Audio Really Matters

Your company probably relies on audio more than you realize. Whether you’re creating a spoken text message to a colleague or giving a speech, you want your audio to shine. Otherwise, you could cause avoidable friction points and potentially hurt your brand reputation. For example, let’s say you create a

chrome os developer mode

How to Turn on Chrome OS Developer Mode

Google’s Chrome OS is a popular operating system that is widely used on Chromebooks and other devices. While it is designed to be simple and user-friendly, there are times when users may want to access additional features and functionality. One way to do this is by turning on Chrome OS