[llvm] r300300 - Object, LTO: Add target triple to irsymtab and LTO API.
Peter Collingbourne via llvm-commits
llvm-commits at lists.llvm.org
Thu Apr 13 19:55:07 PDT 2017
Author: pcc
Date: Thu Apr 13 21:55:06 2017
New Revision: 300300
URL: http://llvm.org/viewvc/llvm-project?rev=300300&view=rev
Log:
Object, LTO: Add target triple to irsymtab and LTO API.
Start using it in LLD to avoid needing to read bitcode again just to get the
target triple, and in llvm-lto2 to avoid printing symbol table information
that is inappropriate for the target.
Differential Revision: https://reviews.llvm.org/D32038
Added:
llvm/trunk/test/LTO/Resolution/X86/symtab-elf.ll
Modified:
llvm/trunk/include/llvm/LTO/LTO.h
llvm/trunk/include/llvm/Object/IRSymtab.h
llvm/trunk/lib/LTO/LTO.cpp
llvm/trunk/lib/Object/IRSymtab.cpp
llvm/trunk/test/LTO/Resolution/X86/symtab.ll
llvm/trunk/tools/llvm-lto2/llvm-lto2.cpp
Modified: llvm/trunk/include/llvm/LTO/LTO.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/LTO/LTO.h?rev=300300&r1=300299&r2=300300&view=diff
==============================================================================
--- llvm/trunk/include/llvm/LTO/LTO.h (original)
+++ llvm/trunk/include/llvm/LTO/LTO.h Thu Apr 13 21:55:06 2017
@@ -97,7 +97,7 @@ private:
// [begin, end) for each module
std::vector<std::pair<size_t, size_t>> ModuleSymIndices;
- StringRef SourceFileName, COFFLinkerOpts;
+ StringRef TargetTriple, SourceFileName, COFFLinkerOpts;
std::vector<StringRef> ComdatTable;
public:
@@ -138,6 +138,9 @@ public:
/// Returns the path to the InputFile.
StringRef getName() const;
+ /// Returns the input file's target triple.
+ StringRef getTargetTriple() const { return TargetTriple; }
+
/// Returns the source file path specified at compile time.
StringRef getSourceFileName() const { return SourceFileName; }
Modified: llvm/trunk/include/llvm/Object/IRSymtab.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Object/IRSymtab.h?rev=300300&r1=300299&r2=300300&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Object/IRSymtab.h (original)
+++ llvm/trunk/include/llvm/Object/IRSymtab.h Thu Apr 13 21:55:06 2017
@@ -116,7 +116,7 @@ struct Header {
Range<Symbol> Symbols;
Range<Uncommon> Uncommons;
- Str SourceFileName;
+ Str TargetTriple, SourceFileName;
/// COFF-specific: linker directives.
Str COFFLinkerOpts;
@@ -227,6 +227,8 @@ public:
/// copied into an irsymtab::Symbol object.
symbol_range module_symbols(unsigned I) const;
+ StringRef getTargetTriple() const { return str(header().TargetTriple); }
+
/// Returns the source file path specified at compile time.
StringRef getSourceFileName() const { return str(header().SourceFileName); }
Modified: llvm/trunk/lib/LTO/LTO.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/LTO/LTO.cpp?rev=300300&r1=300299&r2=300300&view=diff
==============================================================================
--- llvm/trunk/lib/LTO/LTO.cpp (original)
+++ llvm/trunk/lib/LTO/LTO.cpp Thu Apr 13 21:55:06 2017
@@ -351,6 +351,7 @@ Expected<std::unique_ptr<InputFile>> Inp
irsymtab::Reader R({Symtab.data(), Symtab.size()},
{File->Strtab.data(), File->Strtab.size()});
+ File->TargetTriple = R.getTargetTriple();
File->SourceFileName = R.getSourceFileName();
File->COFFLinkerOpts = R.getCOFFLinkerOpts();
File->ComdatTable = R.getComdatTable();
Modified: llvm/trunk/lib/Object/IRSymtab.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Object/IRSymtab.cpp?rev=300300&r1=300299&r2=300300&view=diff
==============================================================================
--- llvm/trunk/lib/Object/IRSymtab.cpp (original)
+++ llvm/trunk/lib/Object/IRSymtab.cpp Thu Apr 13 21:55:06 2017
@@ -190,6 +190,7 @@ Error Builder::build(ArrayRef<Module *>
storage::Header Hdr;
assert(!IRMods.empty());
+ setStr(Hdr.TargetTriple, IRMods[0]->getTargetTriple());
setStr(Hdr.SourceFileName, IRMods[0]->getSourceFileName());
TT = Triple(IRMods[0]->getTargetTriple());
Added: llvm/trunk/test/LTO/Resolution/X86/symtab-elf.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LTO/Resolution/X86/symtab-elf.ll?rev=300300&view=auto
==============================================================================
--- llvm/trunk/test/LTO/Resolution/X86/symtab-elf.ll (added)
+++ llvm/trunk/test/LTO/Resolution/X86/symtab-elf.ll Thu Apr 13 21:55:06 2017
@@ -0,0 +1,15 @@
+; RUN: llvm-as -o %t %s
+; RUN: llvm-lto2 dump-symtab %t | FileCheck %s
+
+; CHECK: target triple: x86_64-unknown-linux-gnu
+target triple = "x86_64-unknown-linux-gnu"
+target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
+
+; CHECK-NOT: linker opts:
+!0 = !{i32 6, !"Linker Options", !{!{!"/include:foo"}}}
+!llvm.module.flags = !{ !0 }
+
+ at g1 = global i32 0
+
+; CHECK-NOT: fallback g1
+ at g2 = weak alias i32, i32* @g1
Modified: llvm/trunk/test/LTO/Resolution/X86/symtab.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/LTO/Resolution/X86/symtab.ll?rev=300300&r1=300299&r2=300300&view=diff
==============================================================================
--- llvm/trunk/test/LTO/Resolution/X86/symtab.ll (original)
+++ llvm/trunk/test/LTO/Resolution/X86/symtab.ll Thu Apr 13 21:55:06 2017
@@ -1,13 +1,14 @@
; RUN: llvm-as -o %t %s
; RUN: llvm-lto2 dump-symtab %t | FileCheck %s
+; CHECK: target triple: i686-pc-windows-msvc18.0.0
target triple = "i686-pc-windows-msvc18.0.0"
target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
; CHECK: source filename: src.c
source_filename = "src.c"
-; CHECK: linker opts (COFF only): /include:foo
+; CHECK: linker opts: /include:foo
!0 = !{i32 6, !"Linker Options", !{!{!"/include:foo"}}}
!llvm.module.flags = !{ !0 }
Modified: llvm/trunk/tools/llvm-lto2/llvm-lto2.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/tools/llvm-lto2/llvm-lto2.cpp?rev=300300&r1=300299&r2=300300&view=diff
==============================================================================
--- llvm/trunk/tools/llvm-lto2/llvm-lto2.cpp (original)
+++ llvm/trunk/tools/llvm-lto2/llvm-lto2.cpp Thu Apr 13 21:55:06 2017
@@ -293,8 +293,13 @@ static int dumpSymtab(int argc, char **a
std::unique_ptr<InputFile> Input =
check(InputFile::create(MB->getMemBufferRef()), F);
+ outs() << "target triple: " << Input->getTargetTriple() << '\n';
+ Triple TT(Input->getTargetTriple());
+
outs() << "source filename: " << Input->getSourceFileName() << '\n';
- outs() << "linker opts (COFF only): " << Input->getCOFFLinkerOpts() << '\n';
+
+ if (TT.isOSBinFormatCOFF())
+ outs() << "linker opts: " << Input->getCOFFLinkerOpts() << '\n';
std::vector<StringRef> ComdatTable = Input->getComdatTable();
for (const InputFile::Symbol &Sym : Input->symbols()) {
@@ -328,7 +333,7 @@ static int dumpSymtab(int argc, char **a
if (Comdat != -1)
outs() << " comdat " << ComdatTable[Comdat] << '\n';
- if (Sym.isWeak() && Sym.isIndirect())
+ if (TT.isOSBinFormatCOFF() && Sym.isWeak() && Sym.isIndirect())
outs() << " fallback " << Sym.getCOFFWeakExternalFallback() << '\n';
}
More information about the llvm-commits
mailing list