The mangling is different when targeting MSVC ABI, see failure at 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
maybe -triple x86_64-pc-linux ? 2016-10-02 6:06 GMT+03:00 Aditya Kumar via cfe-commits < cfe-commits@lists.llvm.org>: > Author: hiraditya > Date: Sat Oct 1 22:06:36 2016 > New Revision: 283063 > > URL: http://llvm.org/viewvc/llvm-project?rev=283063&view=rev > Log: > Alias must point to a definition > > Reapplying the patch after modifying the test case. > > Inlining the destructor caused the compiler to generate bad IR which > failed the Verifier in the backend. > https://llvm.org/bugs/show_bug.cgi?id=30341 > > This patch disables alias to available_externally definitions. > > Reviewers: eugenis, rsmith > > Differential Revision: https://reviews.llvm.org/D24682 > > Added: > cfe/trunk/test/CodeGenCXX/alias-available-externally.cpp > Modified: > cfe/trunk/lib/CodeGen/CGCXX.cpp > > Modified: cfe/trunk/lib/CodeGen/CGCXX.cpp > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/ > CGCXX.cpp?rev=283063&r1=283062&r2=283063&view=diff > ============================================================ > ================== > --- cfe/trunk/lib/CodeGen/CGCXX.cpp (original) > +++ cfe/trunk/lib/CodeGen/CGCXX.cpp Sat Oct 1 22:06:36 2016 > @@ -134,6 +134,11 @@ bool CodeGenModule::TryEmitDefinitionAsA > llvm::GlobalValue::LinkageTypes TargetLinkage = > getFunctionLinkage(TargetDecl); > > + // available_externally definitions aren't real definitions, so we > cannot > + // create an alias to one. > + if (TargetLinkage == llvm::GlobalValue::AvailableExternallyLinkage) > + return true; > + > // Check if we have it already. > StringRef MangledName = getMangledName(AliasDecl); > llvm::GlobalValue *Entry = GetGlobalValue(MangledName); > @@ -156,14 +161,7 @@ bool CodeGenModule::TryEmitDefinitionAsA > > // Instead of creating as alias to a linkonce_odr, replace all of the > uses > // of the aliasee. > - if (llvm::GlobalValue::isDiscardableIfUnused(Linkage) && > - (TargetLinkage != llvm::GlobalValue::AvailableExternallyLinkage || > - !TargetDecl.getDecl()->hasAttr<AlwaysInlineAttr>())) { > - // FIXME: An extern template instantiation 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. > + if (llvm::GlobalValue::isDiscardableIfUnused(Linkage)) { > addReplacement(MangledName, Aliasee); > return false; > } > > Added: cfe/trunk/test/CodeGenCXX/alias-available-externally.cpp > URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/ > CodeGenCXX/alias-available-externally.cpp?rev=283063&view=auto > ============================================================ > ================== > --- cfe/trunk/test/CodeGenCXX/alias-available-externally.cpp (added) > +++ cfe/trunk/test/CodeGenCXX/alias-available-externally.cpp Sat Oct 1 > 22:06:36 2016 > @@ -0,0 +1,20 @@ > +// RUN: %clang_cc1 -O1 -std=c++11 -emit-llvm -disable-llvm-passes -o - %s > | FileCheck %s > +// Clang should not generate alias to available_externally definitions. > +// Check that the destructor of Foo is defined. > +// The destructors have different return type for different targets. > +// CHECK: define linkonce_odr {{.*}} @_ZN3FooD2Ev > +template <class CharT> > +struct String { > + String() {} > + ~String(); > +}; > + > +template <class CharT> > +inline __attribute__((visibility("hidden"), always_inline)) > +String<CharT>::~String() {} > + > +extern template struct String<char>; > + > +struct Foo : public String<char> { Foo() { String<char> s; } }; > + > +Foo f; > > > _______________________________________________ > cfe-commits mailing list > cfe-commits@lists.llvm.org > http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits >
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits