[lld] r314869 - Call exitLld() from elf::link.

Rui Ueyama via llvm-commits llvm-commits at lists.llvm.org
Mon Oct 23 14:14:41 PDT 2017


Hm, I feel the other way, and this patch guarantees that we call exitLld()
even if we do not reach the end of the writer, which I think a good thing.
Also, if you want to do RAII-ish thing in that function (e.g. printing out
timestamps on function entry and exit), it is convenient if the function
always returns.

On Wed, Oct 18, 2017 at 7:56 PM, Rafael Avila de Espindola <
rafael.espindola at gmail.com> wrote:

> I actually found it a bit easier to understand when the exit was
> immediately after the commit.
>
> Cheers,
> Rafael
>
> Rui Ueyama via llvm-commits <llvm-commits at lists.llvm.org> writes:
>
> > Author: ruiu
> > Date: Tue Oct  3 17:50:11 2017
> > New Revision: 314869
> >
> > URL: http://llvm.org/viewvc/llvm-project?rev=314869&view=rev
> > Log:
> > Call exitLld() from elf::link.
> >
> > We used to call exitLld() from a leaf function, Writer::run(), because
> > we had objects on the stack whose dtors are expensive. Now we no longer
> > have such objects on the stack, so there's no reason to exist from the
> > leaf function.
> >
> > Modified:
> >     lld/trunk/ELF/Driver.cpp
> >     lld/trunk/ELF/Writer.cpp
> >
> > Modified: lld/trunk/ELF/Driver.cpp
> > URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Driver.
> cpp?rev=314869&r1=314868&r2=314869&view=diff
> > ============================================================
> ==================
> > --- lld/trunk/ELF/Driver.cpp (original)
> > +++ lld/trunk/ELF/Driver.cpp Tue Oct  3 17:50:11 2017
> > @@ -89,6 +89,13 @@ bool elf::link(ArrayRef<const char *> Ar
> >    Config->Argv = {Args.begin(), Args.end()};
> >
> >    Driver->main(Args, CanExitEarly);
> > +
> > +  // Exit immediately if we don't need to return to the caller.
> > +  // This saves time because the overhead of calling destructors
> > +  // for all globally-allocated objects is not negligible.
> > +  if (Config->ExitEarly)
> > +    exitLld(ErrorCount ? 1 : 0);
> > +
> >    freeArena();
> >    return !ErrorCount;
> >  }
> >
> > Modified: lld/trunk/ELF/Writer.cpp
> > URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/Writer.
> cpp?rev=314869&r1=314868&r2=314869&view=diff
> > ============================================================
> ==================
> > --- lld/trunk/ELF/Writer.cpp (original)
> > +++ lld/trunk/ELF/Writer.cpp Tue Oct  3 17:50:11 2017
> > @@ -246,12 +246,6 @@ template <class ELFT> void Writer<ELFT>:
> >
> >    if (auto EC = Buffer->commit())
> >      error("failed to write to the output file: " + EC.message());
> > -
> > -  // Flush the output streams and exit immediately. A full shutdown
> > -  // is a good test that we are keeping track of all allocated memory,
> > -  // but actually freeing it is a waste of time in a regular linker run.
> > -  if (Config->ExitEarly)
> > -    exitLld(0);
> >  }
> >
> >  // Initialize Out members.
> >
> >
> > _______________________________________________
> > llvm-commits mailing list
> > llvm-commits at lists.llvm.org
> > http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171023/9821e268/attachment.html>


More information about the llvm-commits mailing list