Atlanta Custom Software Development 

 
   Search        Code/Page
 

User Login
Email

Password

 

Forgot the Password?
Services
» Web Development
» Maintenance
» Data Integration/BI
» Information Management
Programming
  Database
Automation
OS/Networking
Graphics
Links
Tools
» Regular Expr Tester
» Free Tools

The "Assume No Aliasing" compiler option

Total Hit ( 2997)

Rate this article:     Poor     Excellent 

 Submit Your Question/Comment about this article

Rating


 


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:

Click here to copy the following block
Dim g_GlobalVariable As Long
...
Sub ProcWithAliases(x As Long)
  x = x + 1
  g_GlobalVariable = g_GlobalVariable + 1
End 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.



Submitted By : Nayan Patel  (Member Since : 5/26/2004 12:23:06 PM)

Job Description : He is the moderator of this site and currently working as an independent consultant. He works with VB.net/ASP.net, SQL Server and other MS technologies. He is MCSD.net, MCDBA and MCSE. In his free time he likes to watch funny movies and doing oil painting.
View all (893) submissions by this author  (Birth Date : 7/14/1981 )


Home   |  Comment   |  Contact Us   |  Privacy Policy   |  Terms & Conditions   |  BlogsZappySys

© 2008 BinaryWorld LLC. All rights reserved.