[PATCH] D18410: ELF: Split BitcodeCompiler::compile.
Rui Ueyama via llvm-commits
llvm-commits at lists.llvm.org
Wed Mar 23 12:29:08 PDT 2016
+rafael because he added this FIXME.
On Wed, Mar 23, 2016 at 8:26 PM, Mehdi Amini <mehdi.amini at apple.com> wrote:
>
> > On Mar 23, 2016, at 11:38 AM, Rui Ueyama <ruiu at google.com> wrote:
> >
> > ruiu created this revision.
> > ruiu added a reviewer: davide.
> > ruiu added a subscriber: llvm-commits.
> > Herald added a subscriber: joker.eph.
> >
> > ELF: Split BitcodeCompiler::compile.
> >
> > http://reviews.llvm.org/D18410
> >
> > Files:
> > ELF/LTO.cpp
> > ELF/LTO.h
> >
> > Index: ELF/LTO.h
> > ===================================================================
> > --- ELF/LTO.h
> > +++ ELF/LTO.h
> > @@ -39,6 +39,8 @@
> > 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};
> > Index: ELF/LTO.cpp
> > ===================================================================
> > --- ELF/LTO.cpp
> > +++ ELF/LTO.cpp
> > @@ -103,23 +103,7 @@
> > 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);
> > @@ -138,6 +122,22 @@
> > return std::unique_ptr<ObjectFile<ELFT>>(OF);
> > }
> >
> > +TargetMachine *BitcodeCompiler::getTargetMachine() {
> > + StringRef TripleStr = Combined.getTargetTriple();
> > +
> > + // 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.
>
> My 2 cents for the "FIXME" (I know it is code motion): error is the only
> sane solution when a bitcode has been optimized for a Target (using some
> TTI) and the target backend is not available at link time.
> Silently falling back to the host triple could lead to surprises for the
> user. I'm curious if I'm missing a real use case for that?
>
> --
> Mehdi
>
>
> > + 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();
> >
> >
> > <D18410.51455.patch>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20160323/e35481bb/attachment.html>
More information about the llvm-commits
mailing list