diff options
author | Rafael Espindola <rafael.espindola@gmail.com> | 2013-11-05 05:29:54 +0000 |
---|---|---|
committer | Rafael Espindola <rafael.espindola@gmail.com> | 2013-11-05 05:29:54 +0000 |
commit | b5ac86865aeaa5bc63cddaed7b088540394b4ce4 (patch) | |
tree | 30c615cb8ee5c73e8bc6c446a4c11dea72631a99 /clang/lib | |
parent | 5d79a51a45ea9e4156acfd221e6bbe40b7ba2faa (diff) | |
download | bcm5719-llvm-b5ac86865aeaa5bc63cddaed7b088540394b4ce4.tar.gz bcm5719-llvm-b5ac86865aeaa5bc63cddaed7b088540394b4ce4.zip |
Revert "Produce direct calls instead of alias to linkonce_odr functions."
This reverts commit r194046.
Debugging a bootstrap issue.
llvm-svn: 194047
Diffstat (limited to 'clang/lib')
-rw-r--r-- | clang/lib/CodeGen/CGCXX.cpp | 41 |
1 files changed, 18 insertions, 23 deletions
diff --git a/clang/lib/CodeGen/CGCXX.cpp b/clang/lib/CodeGen/CGCXX.cpp index ab45e321cbb..25f3e6f4daa 100644 --- a/clang/lib/CodeGen/CGCXX.cpp +++ b/clang/lib/CodeGen/CGCXX.cpp @@ -112,13 +112,28 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl, // support aliases with that linkage, fail. llvm::GlobalValue::LinkageTypes Linkage = getFunctionLinkage(AliasDecl); + llvm::GlobalValue::LinkageTypes TargetLinkage + = getFunctionLinkage(TargetDecl); + + // Don't create an alias to a linker weak symbol unless we know we can do + // that in every TU. This avoids producing different COMDATs in different + // TUs. + if (llvm::GlobalValue::isWeakForLinker(TargetLinkage)) { + if (!InEveryTU) + return true; + + // In addition to making sure we produce it in every TU, we have to make + // sure llvm keeps it. + // FIXME: Instead of outputting an alias we could just replace every use of + // AliasDecl with TargetDecl. + assert(Linkage == TargetLinkage); + Linkage = llvm::GlobalValue::WeakODRLinkage; + } + // We can't use an alias if the linkage is not valid for one. if (!llvm::GlobalAlias::isValidLinkage(Linkage)) return true; - llvm::GlobalValue::LinkageTypes TargetLinkage = - getFunctionLinkage(TargetDecl); - // Check if we have it already. StringRef MangledName = getMangledName(AliasDecl); llvm::GlobalValue *Entry = GetGlobalValue(MangledName); @@ -137,26 +152,6 @@ bool CodeGenModule::TryEmitDefinitionAsAlias(GlobalDecl AliasDecl, if (Ref->getType() != AliasType) Aliasee = llvm::ConstantExpr::getBitCast(Ref, AliasType); - // Don't create an alias to a linker weak symbol unless we know we can do - // that in every TU. This avoids producing different COMDATs in different - // TUs. - if (llvm::GlobalValue::isWeakForLinker(TargetLinkage)) { - if (!InEveryTU) - return true; - - assert(Linkage == TargetLinkage); - // Instead of creating as alias to a linkonce_odr, replace all of the uses - // of the aliassee. - if (TargetLinkage == llvm::GlobalValue::LinkOnceODRLinkage) { - if (!Entry) - return false; - - Entry->replaceAllUsesWith(Aliasee); - Entry->eraseFromParent(); - return false; - } - } - // Create the alias with no name. llvm::GlobalAlias *Alias = new llvm::GlobalAlias(AliasType, Linkage, "", Aliasee, &getModule()); |