Index: clang/lib/CodeGen/CGCXX.cpp =================================================================== --- clang/lib/CodeGen/CGCXX.cpp +++ clang/lib/CodeGen/CGCXX.cpp @@ -134,6 +134,10 @@ llvm::GlobalValue::LinkageTypes TargetLinkage = getFunctionLinkage(TargetDecl); + // r254170: Disallow aliases to available_externally. + if (TargetLinkage == llvm::GlobalValue::AvailableExternallyLinkage) + return true; + // Check if we have it already. StringRef MangledName = getMangledName(AliasDecl); llvm::GlobalValue *Entry = GetGlobalValue(MangledName); @@ -157,8 +161,7 @@ // 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())) { + !TargetDecl.getDecl()->hasAttr()) { // 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