<div dir="rtl"><div dir="ltr">yes, it works, thanks!</div></div><div class="gmail_extra"><div dir="ltr"><br><div class="gmail_quote">2016-10-03 18:19 GMT+03:00 Aditya K <span dir="ltr"><<a href="mailto:hiraditya@msn.com" target="_blank">hiraditya@msn.com</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 .8ex;border-left:1px #ccc solid;border-right:1px #ccc solid;padding-left:1ex;padding-right:1ex">
<div id="m_7200286629637459036divtagdefaultwrapper" style="font-size:12pt;color:#000000;font-family:Calibri,Arial,Helvetica,sans-serif">
<p>Thanks for poining that out. I have updated the test case, please see if that works.</p>
<p><br>
</p>
<p><a href="http://llvm.org/viewvc/llvm-project?view=revision&revision=283085" class="m_7200286629637459036OWAAutoLink" id="m_7200286629637459036LPlnk188514" target="_blank">http://llvm.org/viewvc/llvm-<wbr>project?view=revision&<wbr>revision=283085</a><br>
</p>
<p><br>
</p>
<p><br>
</p>
<p>-Aditya</p>
<br>
<br>
<div style="color:rgb(0,0,0)">
<hr style="display:inline-block;width:98%">
<div id="m_7200286629637459036divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Yaron Keren <<a href="mailto:yaron.keren@gmail.com" target="_blank">yaron.keren@gmail.com</a>><br>
<b>Sent:</b> Sunday, October 2, 2016 11:32 AM<br>
<b>To:</b> Aditya Kumar<br>
<b>Cc:</b> cfe-commits<br>
<b>Subject:</b> Re: r283063 - Alias must point to a definition</font>
<div> </div>
</div><div><div class="h5">
<div>
<div dir="rtl">
<div dir="ltr">The mangling is different when targeting MSVC ABI, see failure at</div>
<div dir="ltr"><br>
</div>
<div dir="ltr"><a href="http://bb.pgr.jp/builders/ninja-x64-msvc-RA-centos6/builds/29889/steps/test_all/logs/Clang%20%3A%3A%20CodeGenCXX__alias-available-externally.cpp" id="m_7200286629637459036LPlnk101126" target="_blank">http://bb.pgr.jp/builders/<wbr>ninja-x64-msvc-RA-centos6/<wbr>builds/29889/steps/test_all/<wbr>logs/Clang%20%3A%3A%<wbr>20CodeGenCXX__alias-available-<wbr>externally.cpp</a><br>
</div>
<div dir="ltr"><br>
</div>
<div dir="ltr">maybe   -triple x86_64-pc-linux  ?</div>
</div>
<div class="gmail_extra"><br>
<div class="gmail_quote">
<div dir="ltr">2016-10-02 6:06 GMT+03:00 Aditya Kumar via cfe-commits <span dir="ltr">
<<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a>></span>:</div>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: hiraditya<br>
Date: Sat Oct  1 22:06:36 2016<br>
New Revision: 283063<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=283063&view=rev" rel="noreferrer" target="_blank">
http://llvm.org/viewvc/llvm-pr<wbr>oject?rev=283063&view=rev</a><br>
Log:<br>
Alias must point to a definition<br>
<br>
Reapplying the patch after modifying the test case.<br>
<br>
Inlining the destructor caused the compiler to generate bad IR which failed the Verifier in the backend.<br>
<a href="https://llvm.org/bugs/show_bug.cgi?id=30341" rel="noreferrer" target="_blank">https://llvm.org/bugs/show_bug<wbr>.cgi?id=30341</a><br>
<br>
This patch disables alias to available_externally definitions.<br>
<br>
Reviewers: eugenis, rsmith<br>
<br>
Differential Revision: <a href="https://reviews.llvm.org/D24682" rel="noreferrer" target="_blank">
https://reviews.llvm.org/D2468<wbr>2</a><br>
<br>
Added:<br>
    cfe/trunk/test/CodeGenCXX/alia<wbr>s-available-externally.cpp<br>
Modified:<br>
    cfe/trunk/lib/CodeGen/CGCXX.cp<wbr>p<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGCXX.cp<wbr>p<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCXX.cpp?rev=283063&r1=283062&r2=283063&view=diff" rel="noreferrer" target="_blank">
http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/lib/CodeGen/CG<wbr>CXX.cpp?rev=283063&r1=283062&<wbr>r2=283063&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/CodeGen/CGCXX.cp<wbr>p (original)<br>
+++ cfe/trunk/lib/CodeGen/CGCXX.cp<wbr>p Sat Oct  1 22:06:36 2016<br>
@@ -134,6 +134,11 @@ bool CodeGenModule::TryEmitDefiniti<wbr>onAsA<br>
   llvm::GlobalValue::LinkageTyp<wbr>es TargetLinkage =<br>
       getFunctionLinkage(<wbr>TargetDecl);<br>
<br>
+  // available_externally definitions aren't real definitions, so we cannot<br>
+  // create an alias to one.<br>
+  if (TargetLinkage == llvm::GlobalValue::AvailableEx<wbr>ternallyLinkage)<br>
+    return true;<br>
+<br>
   // Check if we have it already.<br>
   StringRef MangledName = getMangledName(AliasDecl);<br>
   llvm::GlobalValue *Entry = GetGlobalValue(MangledName);<br>
@@ -156,14 +161,7 @@ bool CodeGenModule::TryEmitDefiniti<wbr>onAsA<br>
<br>
   // Instead of creating as alias to a linkonce_odr, replace all of the uses<br>
   // of the aliasee.<br>
-  if (llvm::GlobalValue::isDiscarda<wbr>bleIfUnused(Linkage) &&<br>
-     (TargetLinkage != llvm::GlobalValue::AvailableEx<wbr>ternallyLinkage ||<br>
-      !TargetDecl.getDecl()->hasAttr<wbr><AlwaysInlineAttr>())) {<br>
-    // FIXME: An extern template instantiation will create functions with<br>
-    // linkage "AvailableExternally". In libc++, some classes also define<br>
-    // members with attribute "AlwaysInline" and expect no reference to<br>
-    // be generated. It is desirable to reenable this optimisation after<br>
-    // corresponding LLVM changes.<br>
+  if (llvm::GlobalValue::isDiscarda<wbr>bleIfUnused(Linkage)) {<br>
     addReplacement(MangledName, Aliasee);<br>
     return false;<br>
   }<br>
<br>
Added: cfe/trunk/test/CodeGenCXX/alia<wbr>s-available-externally.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenCXX/alias-available-externally.cpp?rev=283063&view=auto" rel="noreferrer" target="_blank">
http://llvm.org/viewvc/llvm-pr<wbr>oject/cfe/trunk/test/CodeGenCX<wbr>X/alias-available-externally.<wbr>cpp?rev=283063&view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/CodeGenCXX/alia<wbr>s-available-externally.cpp (added)<br>
+++ cfe/trunk/test/CodeGenCXX/alia<wbr>s-available-externally.cpp Sat Oct  1 22:06:36 2016<br>
@@ -0,0 +1,20 @@<br>
+// RUN: %clang_cc1 -O1 -std=c++11 -emit-llvm -disable-llvm-passes -o - %s | FileCheck %s<br>
+// Clang should not generate alias to available_externally definitions.<br>
+// Check that the destructor of Foo is defined.<br>
+// The destructors have different return type for different targets.<br>
+// CHECK: define linkonce_odr {{.*}} @_ZN3FooD2Ev<br>
+template <class CharT><br>
+struct String {<br>
+  String() {}<br>
+  ~String();<br>
+};<br>
+<br>
+template <class CharT><br>
+inline __attribute__((visibility("hid<wbr>den"), always_inline))<br>
+String<CharT>::~String() {}<br>
+<br>
+extern template struct String<char>;<br>
+<br>
+struct Foo : public String<char> { Foo() { String<char> s; } };<br>
+<br>
+Foo f;<br>
<br>
<br>
______________________________<wbr>_________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@lists.llvm.org" target="_blank">cfe-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/<wbr>mailman/listinfo/cfe-commits</a><br>
</blockquote>
</div>
<br>
</div>
</div>
</div></div></div>
</div>
</blockquote></div></div></div>