Internalize linkonce_odr more often.

Since there is a copy in every translation unit that uses them, they can
be omitted from the symbol table if the address is not significant.

This still doesn't catch as many cases as the gold plugin. The
difference is that we check canBeOmittedFromSymbolTable in each file and
use lazy loading which limits what it can do. Gold checks it in the merged file.

I think the correct way of getting the same results as gold is just to
cache in the IR the result of canBeOmittedFromSymbolTable.

llvm-svn: 267063
This commit is contained in:
Rafael Espindola
2016-04-21 21:44:25 +00:00
parent c34a519407
commit 4d480ed545
5 changed files with 45 additions and 5 deletions

View File

@@ -12,6 +12,7 @@
#include "InputSection.h"
#include "Symbols.h"
#include "llvm/ADT/STLExtras.h"
#include "llvm/CodeGen/Analysis.h"
#include "llvm/IR/LLVMContext.h"
#include "llvm/IR/Module.h"
#include "llvm/Object/IRObjectFile.h"
@@ -498,8 +499,11 @@ BitcodeFile::createSymbolBody(const DenseSet<const Comdat *> &KeptComdats,
Body = new (Alloc) DefinedBitcode(NameRef, IsWeak, Visibility);
}
// FIXME: Expose a thread-local flag for module asm symbols.
if (GV && GV->isThreadLocal())
Body->Type = STT_TLS;
if (GV) {
if (GV->isThreadLocal())
Body->Type = STT_TLS;
Body->CanOmitFromDynSym = canBeOmittedFromSymbolTable(GV);
}
return Body;
}