The “Assume No Aliasing” compiler option

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:
XDR solutions

The Benefits of Using XDR Solutions

Cybercriminals constantly adapt their strategies, developing newer, more powerful, and intelligent ways to attack your network. Since security professionals must innovate as well, more conventional endpoint detection solutions have evolved

AI is revolutionizing fraud detection

How AI is Revolutionizing Fraud Detection

Artificial intelligence – commonly known as AI – means a form of technology with multiple uses. As a result, it has become extremely valuable to a number of businesses across

AI innovation

Companies Leading AI Innovation in 2023

Artificial intelligence (AI) has been transforming industries and revolutionizing business operations. AI’s potential to enhance efficiency and productivity has become crucial to many businesses. As we move into 2023, several

data fivetran pricing

Fivetran Pricing Explained

One of the biggest trends of the 21st century is the massive surge in analytics. Analytics is the process of utilizing data to drive future decision-making. With so much of

kubernetes logging

Kubernetes Logging: What You Need to Know

Kubernetes from Google is one of the most popular open-source and free container management solutions made to make managing and deploying applications easier. It has a solid architecture that makes

ransomware cyber attack

Why Is Ransomware Such a Major Threat?

One of the most significant cyber threats faced by modern organizations is a ransomware attack. Ransomware attacks have grown in both sophistication and frequency over the past few years, forcing

data dictionary

Tools You Need to Make a Data Dictionary

Data dictionaries are crucial for organizations of all sizes that deal with large amounts of data. they are centralized repositories of all the data in organizations, including metadata such as