[lld] r264193 - ELF: Split BitcodeCompiler::compile.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 23 14:19:27 PDT 2016
Author: ruiu
Date: Wed Mar 23 16:19:27 2016
New Revision: 264193
URL: http://llvm.org/viewvc/llvm-project?rev=264193&view=rev
Log:
ELF: Split BitcodeCompiler::compile.
http://reviews.llvm.org/D18410
Modified:
lld/trunk/ELF/LTO.cpp
lld/trunk/ELF/LTO.h
Modified: lld/trunk/ELF/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LTO.cpp?rev=264193&r1=264192&r2=264193&view=diff
==============================================================================
--- lld/trunk/ELF/LTO.cpp (original)
+++ lld/trunk/ELF/LTO.cpp Wed Mar 23 16:19:27 2016
@@ -111,23 +111,7 @@ std::unique_ptr<elf::ObjectFile<ELFT>> B
if (Config->SaveTemps)
saveBCFile(Combined, ".lto.bc");
- StringRef TripleStr = Combined.getTargetTriple();
- Triple TheTriple(TripleStr);
-
- // FIXME: Should we have a default triple? The gold plugin uses
- // sys::getDefaultTargetTriple(), but that is probably wrong given that this
- // might be a cross linker.
-
- std::string ErrMsg;
- const Target *TheTarget = TargetRegistry::lookupTarget(TripleStr, ErrMsg);
- if (!TheTarget)
- fatal("target not found: " + ErrMsg);
-
- TargetOptions Options;
- Reloc::Model R = Config->Pic ? Reloc::PIC_ : Reloc::Static;
- std::unique_ptr<TargetMachine> TM(
- TheTarget->createTargetMachine(TripleStr, "", "", Options, R));
-
+ std::unique_ptr<TargetMachine> TM(getTargetMachine());
runLTOPasses(Combined, *TM);
raw_svector_ostream OS(OwningData);
@@ -146,6 +130,17 @@ std::unique_ptr<elf::ObjectFile<ELFT>> B
return std::unique_ptr<ObjectFile<ELFT>>(OF);
}
+TargetMachine *BitcodeCompiler::getTargetMachine() {
+ StringRef TripleStr = Combined.getTargetTriple();
+ std::string Msg;
+ const Target *T = TargetRegistry::lookupTarget(TripleStr, Msg);
+ if (!T)
+ fatal("target not found: " + Msg);
+ TargetOptions Options;
+ 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();
Modified: lld/trunk/ELF/LTO.h
URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/LTO.h?rev=264193&r1=264192&r2=264193&view=diff
==============================================================================
--- lld/trunk/ELF/LTO.h (original)
+++ lld/trunk/ELF/LTO.h Wed Mar 23 16:19:27 2016
@@ -39,6 +39,8 @@ public:
template <class ELFT> std::unique_ptr<ObjectFile<ELFT>> compile();
private:
+ llvm::TargetMachine *getTargetMachine();
+
llvm::LLVMContext Context;
llvm::Module Combined{"ld-temp.o", Context};
llvm::IRMover Mover{Combined};
More information about the llvm-commits
mailing list