Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What form of alias analysis does Visual C++ use?

I'm trying to figure out what form of alias analysis is used in Visual C++. It's also known as pointer analysis, mod-ref analysis, points-to analysis or side-effect analysis, and is pretty close to escape analysis or shape analysis (should you have seen those terms bandied about).

If anyone knows where MSDN discusses this sort of thing, I can probably find my way from there. (I tried searching, but MSDN seems to be impenetrable if you don't spend much time there.)

like image 560
Paul Biggar Avatar asked Aug 31 '09 16:08

Paul Biggar


1 Answers

Going purely by MSDN documentation:

"Assume No aliasing" (/Oa) and related options have been removed in Visual Studio 2008.

__declspec(restrict) and __declspec(noalias) have been added (2003 or earlier, see also Optimization best practices)

From that I would conclude that the compiler/optimizer by default assumes aliasing under the C++ rules (roughly, pointers of the same type may point to the same memory). This seems a sensible move in avoiding errors due to a global overly agressive /Oa option.

I would further assume that link-time code generation increases the scope in which non-aliasing can be detected.


The best non-MSDN reference I could find is this: VC++ team blog. However, this just indicates that the compiler does spend some time on alias analysis. Maybe the Channel9 video linked gives some insight.

(Some people had luck with asking for more info in the VC++ comments. Hint hint...)


[edit] I don't know if Phoenix ended up in VS2010, the video talks about aliasing 6:00, but nothing spectacular.

like image 165
peterchen Avatar answered Nov 01 '22 09:11

peterchen