[lld] r314869 - Call exitLld() from elf::link.
Rafael Avila de Espindola via llvm-commits
llvm-commits at lists.llvm.org
Wed Oct 18 19:56:02 PDT 2017
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
More information about the llvm-commits
mailing list