[llvm-branch-commits] [cfe-branch] r195615 - Merging r195501:

Bill Wendling isanbard at gmail.com
Sun Nov 24 21:40:33 PST 2013


Author: void
Date: Sun Nov 24 23:40:33 2013
New Revision: 195615

URL: http://llvm.org/viewvc/llvm-project?rev=195615&view=rev
Log:
Merging r195501:
------------------------------------------------------------------------
r195501 | joerg | 2013-11-22 13:34:35 -0800 (Fri, 22 Nov 2013) | 5 lines

Adjust r194296 to not apply the alias replacement for externally
available always-inline functions. This breaks libc++'s locale
implementation. Code generation for this case should be fixed, but this
is a stop gap fix for clang 3.4.

------------------------------------------------------------------------

Modified:
    cfe/branches/release_34/   (props changed)
    cfe/branches/release_34/lib/CodeGen/CGCXX.cpp
    cfe/branches/release_34/test/CodeGenCXX/ctor-dtor-alias.cpp

Propchange: cfe/branches/release_34/
------------------------------------------------------------------------------
--- svn:mergeinfo (original)
+++ svn:mergeinfo Sun Nov 24 23:40:33 2013
@@ -1,4 +1,4 @@
 /cfe/branches/type-system-rewrite:134693-134817
-/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195268,195283,195326,195329,195367,195384,195547
+/cfe/trunk:195126,195128,195135-195136,195146,195149,195154,195158,195163,195168,195174,195268,195283,195326,195329,195367,195384,195501,195547
 /cfe/trunk/test:170344
 /cfe/trunk/test/SemaTemplate:126920

Modified: cfe/branches/release_34/lib/CodeGen/CGCXX.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/lib/CodeGen/CGCXX.cpp?rev=195615&r1=195614&r2=195615&view=diff
==============================================================================
--- cfe/branches/release_34/lib/CodeGen/CGCXX.cpp (original)
+++ cfe/branches/release_34/lib/CodeGen/CGCXX.cpp Sun Nov 24 23:40:33 2013
@@ -140,7 +140,14 @@ bool CodeGenModule::TryEmitDefinitionAsA
 
   // 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) &&
+     (TargetLinkage != llvm::GlobalValue::AvailableExternallyLinkage ||
+      !TargetDecl.getDecl()->hasAttr<AlwaysInlineAttr>())) {
+    // FIXME: An extern template instanciation will create functions with
+    // linkage "AvailableExternally". In libc++, some classes also define
+    // members with attribute "AlwaysInline" and expect no reference to
+    // be generated. It is desirable to reenable this optimisation after
+    // corresponding LLVM changes.
     Replacements[MangledName] = Aliasee;
     return false;
   }

Modified: cfe/branches/release_34/test/CodeGenCXX/ctor-dtor-alias.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/branches/release_34/test/CodeGenCXX/ctor-dtor-alias.cpp?rev=195615&r1=195614&r2=195615&view=diff
==============================================================================
--- cfe/branches/release_34/test/CodeGenCXX/ctor-dtor-alias.cpp (original)
+++ cfe/branches/release_34/test/CodeGenCXX/ctor-dtor-alias.cpp Sun Nov 24 23:40:33 2013
@@ -1,6 +1,9 @@
 // RUN: %clang_cc1 %s -triple x86_64-linux -emit-llvm -o - -mconstructor-aliases -O1 -disable-llvm-optzns | FileCheck %s
 // RUN: %clang_cc1 %s -triple x86_64-linux -emit-llvm -o - -mconstructor-aliases | FileCheck --check-prefix=NOOPT %s
 
+// RUN: %clang_cc1 -cc1 -triple x86_64--netbsd -emit-llvm \
+// RUN: -mconstructor-aliases -O2 %s -o - | FileCheck --check-prefix=CHECK-RAUW %s
+
 namespace test1 {
 // test that we don't produce an alias when the destructor is weak_odr. The
 // reason to avoid it that another TU might have no explicit template
@@ -129,3 +132,32 @@ namespace test8 {
   struct zed : public bar {};
   zed foo;
 }
+
+// CHECK-RAUW: @_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;
+}





More information about the llvm-branch-commits mailing list