[lld] r263070 - [lto] Add saving the LTO .o file to -save-temps.

Rafael EspĂ­ndola via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 10 04:59:34 PST 2016


Just a small thing I noticed, maybe you want to run llvm-dis on
%t.so.lto.bc just to show it is bitcode?

Cheers,
Rafael


On 9 March 2016 at 17:30, Sean Silva via llvm-commits
<llvm-commits at lists.llvm.org> wrote:
> Author: silvas
> Date: Wed Mar  9 16:30:05 2016
> New Revision: 263070
>
> URL: http://llvm.org/viewvc/llvm-project?rev=263070&view=rev
> Log:
> [lto] Add saving the LTO .o file to -save-temps.
>
> Summary:
> This implements another part of -save-temps.
> After this, the only remaining part is dumping the optimized bitcode. But
> currently LLD's LTO doesn't have a non-intrusive place to put this.
> Eventually we probably will and it will make sense to add it then.
>
> Reviewers: ruiu, rafael
>
> Subscribers: joker.eph, Bigcheese, llvm-commits
>
> Differential Revision: http://reviews.llvm.org/D18009
>
> Modified:
>     lld/trunk/ELF/SymbolTable.cpp
>     lld/trunk/test/ELF/lto/save-temps.ll
>
> Modified: lld/trunk/ELF/SymbolTable.cpp
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/ELF/SymbolTable.cpp?rev=263070&r1=263069&r2=263070&view=diff
> ==============================================================================
> --- lld/trunk/ELF/SymbolTable.cpp (original)
> +++ lld/trunk/ELF/SymbolTable.cpp Wed Mar  9 16:30:05 2016
> @@ -96,6 +96,15 @@ void SymbolTable<ELFT>::addFile(std::uni
>      resolve(B);
>  }
>
> +// This is for use when debugging LTO.
> +static void saveLtoObjectFile(StringRef Buffer) {
> +  std::error_code EC;
> +  raw_fd_ostream OS(Config->OutputFile.str() + ".lto.o", EC,
> +                    sys::fs::OpenFlags::F_None);
> +  check(EC);
> +  OS << Buffer;
> +}
> +
>  // Codegen the module M and returns the resulting InputFile.
>  template <class ELFT>
>  std::unique_ptr<InputFile> SymbolTable<ELFT>::codegen(Module &M) {
> @@ -123,6 +132,8 @@ std::unique_ptr<InputFile> SymbolTable<E
>      fatal("Failed to setup codegen");
>    CodeGenPasses.run(M);
>    LtoBuffer = MemoryBuffer::getMemBuffer(OwningLTOData, "", false);
> +  if (Config->SaveTemps)
> +    saveLtoObjectFile(LtoBuffer->getBuffer());
>    return createObjectFile(*LtoBuffer);
>  }
>
>
> Modified: lld/trunk/test/ELF/lto/save-temps.ll
> URL: http://llvm.org/viewvc/llvm-project/lld/trunk/test/ELF/lto/save-temps.ll?rev=263070&r1=263069&r2=263070&view=diff
> ==============================================================================
> --- lld/trunk/test/ELF/lto/save-temps.ll (original)
> +++ lld/trunk/test/ELF/lto/save-temps.ll Wed Mar  9 16:30:05 2016
> @@ -1,10 +1,11 @@
>  ; REQUIRES: x86
> -; RUN: rm -f %t.so %t.so.lto.bc
> +; RUN: rm -f %t.so %t.so.lto.bc %t.so.lto.o
>  ; RUN: llvm-as %s -o %t.o
>  ; RUN: llvm-as %p/Inputs/save-temps.ll -o %t2.o
>  ; RUN: ld.lld -shared -m elf_x86_64 %t.o %t2.o -o %t.so -save-temps
>  ; RUN: llvm-nm %t.so | FileCheck %s
>  ; RUN: llvm-nm %t.so.lto.bc | FileCheck %s
> +; RUN: llvm-nm %t.so.lto.o | FileCheck %s
>
>  target triple = "x86_64-unknown-linux-gnu"
>  target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
> @@ -13,5 +14,5 @@ define void @foo() {
>    ret void
>  }
>
> -; CHECK-DAG: T bar
> -; CHECK-DAG: T foo
> +; CHECK: T bar
> +; CHECK: T foo
>
>
> _______________________________________________
> 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