On Fri, Nov 22, 2013 at 08:23:09AM -0500, Rafael Espíndola wrote:
> > How does the attached patch look?
>
> Close, but please:
>
> * Disallow only the "available_externally always_inline" combination.
> Your patch would disable it for all always_inline.
> * Add a comment to the file saying why we don't want to rauw if the
> target is is available_externally always_inline and maybe a FIXME
> about the existence of this combination being a bit odd.
> * clang-format the test :-)
> * merge the test into test/CodeGenCXX/ctor-dtor-alias.cpp
Updated.
Joerg
Index: lib/CodeGen/CGCXX.cpp
===================================================================
--- lib/CodeGen/CGCXX.cpp (revision 195396)
+++ lib/CodeGen/CGCXX.cpp (working copy)
@@ -140,7 +140,11 @@
// 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: The combination of AvailableExternally and AlwaysInline
+ // confuses LLVM. Before should be clarified and the condition dropped.
Replacements[MangledName] = Aliasee;
return false;
}
Index: test/CodeGenCXX/ctor-dtor-alias.cpp
===================================================================
--- test/CodeGenCXX/ctor-dtor-alias.cpp (revision 195396)
+++ test/CodeGenCXX/ctor-dtor-alias.cpp (working copy)
@@ -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 @@
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;
+}
_______________________________________________
cfe-commits mailing list
[email protected]
http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits