On Fri, Nov 08, 2013 at 11:46:20PM -0000, Rafael Espindola wrote:
> Author: rafael
> Date: Fri Nov  8 17:46:20 2013
> New Revision: 194296
> 
> URL: http://llvm.org/viewvc/llvm-project?rev=194296&view=rev
> Log:
> Use rauw for all discardable aliases, not just linkonce_odr.

How does the attached patch look?

Joerg
Index: lib/CodeGen/CGCXX.cpp
===================================================================
--- lib/CodeGen/CGCXX.cpp	(revision 195378)
+++ lib/CodeGen/CGCXX.cpp	(working copy)
@@ -140,7 +140,8 @@
 
   // Instead of creating as alias to a linkonce_odr, replace all of the uses
   // of the aliassee.
-  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage)) {
+  if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) &&
+      !TargetDecl.getDecl()->hasAttr<AlwaysInlineAttr>()) {
     Replacements[MangledName] = Aliasee;
     return false;
   }
Index: test/CodeGen/template-always_inline.cc
===================================================================
--- test/CodeGen/template-always_inline.cc	(revision 0)
+++ test/CodeGen/template-always_inline.cc	(working copy)
@@ -0,0 +1,31 @@
+// RUN: %clang_cc1 -cc1 -triple x86_64--netbsd -emit-llvm \
+// RUN: -mconstructor-aliases -O2 %s -o - | FileCheck %s
+// CHECK: @_ZTV1C = linkonce_odr unnamed_addr constant [4 x i8*] [{{[^@]*}}@_ZTI1C {{[^@]*}}@_ZN1CD2Ev {{[^@]*}}@_ZN1CD0Ev {{[^@]*}}]
+
+// r194296 replaced C::~C with B::~B without emitting the later.
+
+class A
+{
+public:
+    A (int);
+    virtual ~ A ();
+};
+template < class > class B:A
+{
+public:
+    B ():A(0)
+    {
+    } __attribute__ ((always_inline)) ~B ()
+    {
+    }
+};
+
+extern template class B < char >;
+class C:B < char >
+{
+};
+void
+fn1 ()
+{
+    new C;
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits

Reply via email to