forked from OSchip/llvm-project
				
			Make BitcodeCompiler::compile a non-template function. NFC.
llvm-svn: 264770
This commit is contained in:
		
							parent
							
								
									72a58c3e28
								
							
						
					
					
						commit
						01ddc06484
					
				| 
						 | 
					@ -124,8 +124,7 @@ static void internalize(GlobalValue &GV) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Merge all the bitcode files we have seen, codegen the result
 | 
					// Merge all the bitcode files we have seen, codegen the result
 | 
				
			||||||
// and return the resulting ObjectFile.
 | 
					// and return the resulting ObjectFile.
 | 
				
			||||||
template <class ELFT>
 | 
					std::unique_ptr<InputFile> BitcodeCompiler::compile() {
 | 
				
			||||||
std::unique_ptr<elf::ObjectFile<ELFT>> BitcodeCompiler::compile() {
 | 
					 | 
				
			||||||
  for (const auto &Name : InternalizedSyms) {
 | 
					  for (const auto &Name : InternalizedSyms) {
 | 
				
			||||||
    GlobalValue *GV = Combined.getNamedValue(Name.first());
 | 
					    GlobalValue *GV = Combined.getNamedValue(Name.first());
 | 
				
			||||||
    assert(GV);
 | 
					    assert(GV);
 | 
				
			||||||
| 
						 | 
					@ -148,10 +147,7 @@ std::unique_ptr<elf::ObjectFile<ELFT>> BitcodeCompiler::compile() {
 | 
				
			||||||
                                  "LLD-INTERNAL-combined-lto-object", false);
 | 
					                                  "LLD-INTERNAL-combined-lto-object", false);
 | 
				
			||||||
  if (Config->SaveTemps)
 | 
					  if (Config->SaveTemps)
 | 
				
			||||||
    saveLtoObjectFile(MB->getBuffer());
 | 
					    saveLtoObjectFile(MB->getBuffer());
 | 
				
			||||||
 | 
					  return createObjectFile(*MB);
 | 
				
			||||||
  std::unique_ptr<InputFile> IF = createObjectFile(*MB);
 | 
					 | 
				
			||||||
  auto *OF = cast<ObjectFile<ELFT>>(IF.release());
 | 
					 | 
				
			||||||
  return std::unique_ptr<ObjectFile<ELFT>>(OF);
 | 
					 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
TargetMachine *BitcodeCompiler::getTargetMachine() {
 | 
					TargetMachine *BitcodeCompiler::getTargetMachine() {
 | 
				
			||||||
| 
						 | 
					@ -164,8 +160,3 @@ TargetMachine *BitcodeCompiler::getTargetMachine() {
 | 
				
			||||||
  Reloc::Model R = Config->Pic ? Reloc::PIC_ : Reloc::Static;
 | 
					  Reloc::Model R = Config->Pic ? Reloc::PIC_ : Reloc::Static;
 | 
				
			||||||
  return T->createTargetMachine(TripleStr, "", "", Options, R);
 | 
					  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();
 | 
					 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -32,12 +32,12 @@ namespace lld {
 | 
				
			||||||
namespace elf {
 | 
					namespace elf {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class BitcodeFile;
 | 
					class BitcodeFile;
 | 
				
			||||||
template <class ELFT> class ObjectFile;
 | 
					class InputFile;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
class BitcodeCompiler {
 | 
					class BitcodeCompiler {
 | 
				
			||||||
public:
 | 
					public:
 | 
				
			||||||
  void add(BitcodeFile &F);
 | 
					  void add(BitcodeFile &F);
 | 
				
			||||||
  template <class ELFT> std::unique_ptr<ObjectFile<ELFT>> compile();
 | 
					  std::unique_ptr<InputFile> compile();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
private:
 | 
					private:
 | 
				
			||||||
  llvm::TargetMachine *getTargetMachine();
 | 
					  llvm::TargetMachine *getTargetMachine();
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -101,7 +101,8 @@ template <class ELFT> void SymbolTable<ELFT>::addCombinedLtoObject() {
 | 
				
			||||||
  Lto.reset(new BitcodeCompiler);
 | 
					  Lto.reset(new BitcodeCompiler);
 | 
				
			||||||
  for (const std::unique_ptr<BitcodeFile> &F : BitcodeFiles)
 | 
					  for (const std::unique_ptr<BitcodeFile> &F : BitcodeFiles)
 | 
				
			||||||
    Lto->add(*F);
 | 
					    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.
 | 
					  // Replace bitcode symbols.
 | 
				
			||||||
  llvm::DenseSet<StringRef> DummyGroups;
 | 
					  llvm::DenseSet<StringRef> DummyGroups;
 | 
				
			||||||
| 
						 | 
					@ -113,7 +114,7 @@ template <class ELFT> void SymbolTable<ELFT>::addCombinedLtoObject() {
 | 
				
			||||||
      continue;
 | 
					      continue;
 | 
				
			||||||
    Sym->Body = Body;
 | 
					    Sym->Body = Body;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
  ObjectFiles.push_back(std::move(Obj));
 | 
					  ObjectFiles.emplace_back(Obj);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Add an undefined symbol.
 | 
					// Add an undefined symbol.
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue