<div>I think I found out why: <a href="https://blogs.msdn.microsoft.com/vcblog/2013/09/11/introducing-gw-compiler-switch/">https://blogs.msdn.microsoft.com/vcblog/2013/09/11/introducing-gw-compiler-switch/</a></div><div><br></div><div>"<em style="box-sizing:inherit;font-family:'Segoe UI',SegoeUI,tahoma,sans-serif;font-size:14px;margin:0px;padding:0px;vertical-align:baseline;border:0px;outline:0px;color:rgb(69,69,69)">Please note</em><span style="color:rgb(69,69,69);font-family:WOL_Reg,'Segoe UI',Tahoma,Arial,sans-serif;font-size:14px;background-color:rgb(255,255,255)">, the ICF optimization will only be applied for identical COMDATs where their address is not taken, and they are read only. If a data is not address taken, then breaking address uniqueness by ICF won’t lead to any observable difference, thus it is valid and conformant to the standard."</span></div><div><br><div class="gmail_quote"><div>On Wed, Mar 1, 2017 at 3:40 PM Peter Collingbourne via Phabricator <<a href="mailto:reviews@reviews.llvm.org">reviews@reviews.llvm.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">pcc added a comment.<br class="gmail_msg">
<br class="gmail_msg">
In <a href="https://reviews.llvm.org/D30363#689809" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D30363#689809</a>, @rnk wrote:<br class="gmail_msg">
<br class="gmail_msg">
> In <a href="https://reviews.llvm.org/D30363#687837" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D30363#687837</a>, @pcc wrote:<br class="gmail_msg">
><br class="gmail_msg">
> > Reid, I think you mentioned that you saw this problem only with LLD, do you have any more details?<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
> The one instance that I remember was <a href="http://crbug.com/635943" rel="noreferrer" class="gmail_msg" target="_blank">http://crbug.com/635943</a>. I think there was one other issue much earlier on that didn't require a restructuring.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
Standalone reproducer:<br class="gmail_msg">
<br class="gmail_msg">
  C:\src\icftest>type icftest.cc<br class="gmail_msg">
  #include <stdio.h><br class="gmail_msg">
<br class="gmail_msg">
  extern const wchar_t foo[];<br class="gmail_msg">
  extern const wchar_t bar[];<br class="gmail_msg">
<br class="gmail_msg">
  const wchar_t foo[] = L"";<br class="gmail_msg">
  const wchar_t bar[] = L"";<br class="gmail_msg">
<br class="gmail_msg">
  int main() {<br class="gmail_msg">
    printf("%p %p\n", &foo, &bar);<br class="gmail_msg">
  }<br class="gmail_msg">
<br class="gmail_msg">
  C:\src\icftest>cl /Gw /O2 /c icftest.cc<br class="gmail_msg">
  Microsoft (R) C/C++ Optimizing Compiler Version 19.00.24215.1 for x64<br class="gmail_msg">
  Copyright (C) Microsoft Corporation.  All rights reserved.<br class="gmail_msg">
<br class="gmail_msg">
  icftest.cc<br class="gmail_msg">
<br class="gmail_msg">
  C:\src\icftest>link icftest.obj /opt:icf<br class="gmail_msg">
  Microsoft (R) Incremental Linker Version 14.00.24215.1<br class="gmail_msg">
  Copyright (C) Microsoft Corporation.  All rights reserved.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
  C:\src\icftest>icftest<br class="gmail_msg">
  000000013F2C12C0 000000013F2C12C4<br class="gmail_msg">
<br class="gmail_msg">
  C:\src\icftest>..\llvm-project\ra\bin\lld-link icftest.obj /opt:icf<br class="gmail_msg">
<br class="gmail_msg">
  C:\src\icftest>icftest<br class="gmail_msg">
  000000013FC02088 000000013FC02088<br class="gmail_msg">
<br class="gmail_msg">
So it does appear that MSVC's behaviour is not as documented at least some of the time. In that case I think I'd be fine with this change with an explanatory comment.<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<a href="https://reviews.llvm.org/D30363" rel="noreferrer" class="gmail_msg" target="_blank">https://reviews.llvm.org/D30363</a><br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
<br class="gmail_msg">
</blockquote></div></div>