<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css" style="display:none;"><!-- P {margin-top:0;margin-bottom:0;} --></style>
</head>
<body dir="ltr">
<div id="divtagdefaultwrapper" 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="OWAAutoLink" id="LPlnk188514" previewremoved="true">http://llvm.org/viewvc/llvm-project?view=revision&revision=283085</a><br>
</p>
<p><br>
</p>
<p><br>
</p>
<p>-Aditya</p>
<br>
<br>
<div style="color: rgb(0, 0, 0);">
<hr tabindex="-1" style="display:inline-block; width:98%">
<div id="divRplyFwdMsg" dir="ltr"><font face="Calibri, sans-serif" color="#000000" style="font-size:11pt"><b>From:</b> Yaron Keren <yaron.keren@gmail.com><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 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="LPlnk101126" previewremoved="true">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</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-<wbr>project?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_<wbr>bug.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/<wbr>D24682</a><br>
<br>
Added:<br>
    cfe/trunk/test/CodeGenCXX/<wbr>alias-available-externally.cpp<br>
Modified:<br>
    cfe/trunk/lib/CodeGen/CGCXX.<wbr>cpp<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CGCXX.<wbr>cpp<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-<wbr>project/cfe/trunk/lib/CodeGen/<wbr>CGCXX.cpp?rev=283063&r1=<wbr>283062&r2=283063&view=diff</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/lib/CodeGen/CGCXX.<wbr>cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CGCXX.<wbr>cpp Sat Oct  1 22:06:36 2016<br>
@@ -134,6 +134,11 @@ bool CodeGenModule::<wbr>TryEmitDefinitionAsA<br>
   llvm::GlobalValue::<wbr>LinkageTypes TargetLinkage =<br>
       getFunctionLinkage(TargetDecl)<wbr>;<br>
<br>
+  // available_externally definitions aren't real definitions, so we cannot<br>
+  // create an alias to one.<br>
+  if (TargetLinkage == llvm::GlobalValue::<wbr>AvailableExternallyLinkage)<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::<wbr>TryEmitDefinitionAsA<br>
<br>
   // Instead of creating as alias to a linkonce_odr, replace all of the uses<br>
   // of the aliasee.<br>
-  if (llvm::GlobalValue::<wbr>isDiscardableIfUnused(Linkage) &&<br>
-     (TargetLinkage != llvm::GlobalValue::<wbr>AvailableExternallyLinkage ||<br>
-      !TargetDecl.getDecl()-><wbr>hasAttr<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::<wbr>isDiscardableIfUnused(Linkage)<wbr>) {<br>
     addReplacement(MangledName, Aliasee);<br>
     return false;<br>
   }<br>
<br>
Added: cfe/trunk/test/CodeGenCXX/<wbr>alias-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-<wbr>project/cfe/trunk/test/<wbr>CodeGenCXX/alias-available-<wbr>externally.cpp?rev=283063&<wbr>view=auto</a><br>
==============================<wbr>==============================<wbr>==================<br>
--- cfe/trunk/test/CodeGenCXX/<wbr>alias-available-externally.cpp (added)<br>
+++ cfe/trunk/test/CodeGenCXX/<wbr>alias-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("<wbr>hidden"), 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">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>
</body>
</html>