8

我试图弄清楚Visual C++ 中使用了何种形式的别名分析。它也被称为指针分析、mod-ref 分析、指向分析或副作用分析,并且非常接近逃逸分析或形状分析(如果您已经看到这些术语被大肆宣传)。

如果有人知道 MSDN 在哪里讨论过这类事情,我可能会从那里找到方法。(我试过搜索,但如果你不花太多时间在那里,MSDN 似乎是不可理解的。)

4

1 回答 1

2

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.

于 2012-04-23T14:02:58.713 回答