Make BitcodeCompiler::compile a non-template function. NFC.

llvm-svn: 264770
This commit is contained in:
Rui Ueyama 2016-03-29 19:08:46 +00:00
parent 72a58c3e28
commit 01ddc06484
3 changed files with 7 additions and 15 deletions

View File

@ -124,8 +124,7 @@ static void internalize(GlobalValue &GV) {
// Merge all the bitcode files we have seen, codegen the result
// and return the resulting ObjectFile.
template <class ELFT>
std::unique_ptr<elf::ObjectFile<ELFT>> BitcodeCompiler::compile() {
std::unique_ptr<InputFile> BitcodeCompiler::compile() {
for (const auto &Name : InternalizedSyms) {
GlobalValue *GV = Combined.getNamedValue(Name.first());
assert(GV);
@ -148,10 +147,7 @@ std::unique_ptr<elf::ObjectFile<ELFT>> BitcodeCompiler::compile() {
"LLD-INTERNAL-combined-lto-object", false);
if (Config->SaveTemps)
saveLtoObjectFile(MB->getBuffer());
std::unique_ptr<InputFile> IF = createObjectFile(*MB);
auto *OF = cast<ObjectFile<ELFT>>(IF.release());
return std::unique_ptr<ObjectFile<ELFT>>(OF);
return createObjectFile(*MB);
}
TargetMachine *BitcodeCompiler::getTargetMachine() {
@ -164,8 +160,3 @@ TargetMachine *BitcodeCompiler::getTargetMachine() {
Reloc::Model R = Config->Pic ? Reloc::PIC_ : Reloc::Static;
return T->createTargetMachine(TripleStr, "", "", Options, R);
}
template std::unique_ptr<elf::ObjectFile<ELF32LE>> BitcodeCompiler::compile();
template std::unique_ptr<elf::ObjectFile<ELF32BE>> BitcodeCompiler::compile();
template std::unique_ptr<elf::ObjectFile<ELF64LE>> BitcodeCompiler::compile();
template std::unique_ptr<elf::ObjectFile<ELF64BE>> BitcodeCompiler::compile();

View File

@ -32,12 +32,12 @@ namespace lld {
namespace elf {
class BitcodeFile;
template <class ELFT> class ObjectFile;
class InputFile;
class BitcodeCompiler {
public:
void add(BitcodeFile &F);
template <class ELFT> std::unique_ptr<ObjectFile<ELFT>> compile();
std::unique_ptr<InputFile> compile();
private:
llvm::TargetMachine *getTargetMachine();

View File

@ -101,7 +101,8 @@ template <class ELFT> void SymbolTable<ELFT>::addCombinedLtoObject() {
Lto.reset(new BitcodeCompiler);
for (const std::unique_ptr<BitcodeFile> &F : BitcodeFiles)
Lto->add(*F);
std::unique_ptr<ObjectFile<ELFT>> Obj = Lto->compile<ELFT>();
std::unique_ptr<InputFile> IF = Lto->compile();
ObjectFile<ELFT> *Obj = cast<ObjectFile<ELFT>>(IF.release());
// Replace bitcode symbols.
llvm::DenseSet<StringRef> DummyGroups;
@ -113,7 +114,7 @@ template <class ELFT> void SymbolTable<ELFT>::addCombinedLtoObject() {
continue;
Sym->Body = Body;
}
ObjectFiles.push_back(std::move(Obj));
ObjectFiles.emplace_back(Obj);
}
// Add an undefined symbol.