llvm.org GIT mirror llvm / a9b9e01
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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@300300 91177308-0d34-0410-b5e6-96231b3b80d8 Peter Collingbourne 3 years ago
7 changed file(s) with 33 addition(s) and 5 deletion(s). Raw diff Collapse all Expand all
9696 // [begin, end) for each module
9797 std::vector> ModuleSymIndices;
9898
99 StringRef SourceFileName, COFFLinkerOpts;
99 StringRef TargetTriple, SourceFileName, COFFLinkerOpts;
100100 std::vector ComdatTable;
101101
102102 public:
136136
137137 /// Returns the path to the InputFile.
138138 StringRef getName() const;
139
140 /// Returns the input file's target triple.
141 StringRef getTargetTriple() const { return TargetTriple; }
139142
140143 /// Returns the source file path specified at compile time.
141144 StringRef getSourceFileName() const { return SourceFileName; }
115115 Range Symbols;
116116 Range Uncommons;
117117
118 Str SourceFileName;
118 Str TargetTriple, SourceFileName;
119119
120120 /// COFF-specific: linker directives.
121121 Str COFFLinkerOpts;
226226 /// copied into an irsymtab::Symbol object.
227227 symbol_range module_symbols(unsigned I) const;
228228
229 StringRef getTargetTriple() const { return str(header().TargetTriple); }
230
229231 /// Returns the source file path specified at compile time.
230232 StringRef getSourceFileName() const { return str(header().SourceFileName); }
231233
350350
351351 irsymtab::Reader R({Symtab.data(), Symtab.size()},
352352 {File->Strtab.data(), File->Strtab.size()});
353 File->TargetTriple = R.getTargetTriple();
353354 File->SourceFileName = R.getSourceFileName();
354355 File->COFFLinkerOpts = R.getCOFFLinkerOpts();
355356 File->ComdatTable = R.getComdatTable();
189189 storage::Header Hdr;
190190
191191 assert(!IRMods.empty());
192 setStr(Hdr.TargetTriple, IRMods[0]->getTargetTriple());
192193 setStr(Hdr.SourceFileName, IRMods[0]->getSourceFileName());
193194 TT = Triple(IRMods[0]->getTargetTriple());
194195
0 ; RUN: llvm-as -o %t %s
1 ; RUN: llvm-lto2 dump-symtab %t | FileCheck %s
2
3 ; CHECK: target triple: x86_64-unknown-linux-gnu
4 target triple = "x86_64-unknown-linux-gnu"
5 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
6
7 ; CHECK-NOT: linker opts:
8 !0 = !{i32 6, !"Linker Options", !{!{!"/include:foo"}}}
9 !llvm.module.flags = !{ !0 }
10
11 @g1 = global i32 0
12
13 ; CHECK-NOT: fallback g1
14 @g2 = weak alias i32, i32* @g1
0 ; RUN: llvm-as -o %t %s
11 ; RUN: llvm-lto2 dump-symtab %t | FileCheck %s
22
3 ; CHECK: target triple: i686-pc-windows-msvc18.0.0
34 target triple = "i686-pc-windows-msvc18.0.0"
45 target datalayout = "e-m:x-p:32:32-i64:64-f80:32-n8:16:32-a:0:32-S32"
56
67 ; CHECK: source filename: src.c
78 source_filename = "src.c"
89
9 ; CHECK: linker opts (COFF only): /include:foo
10 ; CHECK: linker opts: /include:foo
1011 !0 = !{i32 6, !"Linker Options", !{!{!"/include:foo"}}}
1112 !llvm.module.flags = !{ !0 }
1213
292292 std::unique_ptr Input =
293293 check(InputFile::create(MB->getMemBufferRef()), F);
294294
295 outs() << "target triple: " << Input->getTargetTriple() << '\n';
296 Triple TT(Input->getTargetTriple());
297
295298 outs() << "source filename: " << Input->getSourceFileName() << '\n';
296 outs() << "linker opts (COFF only): " << Input->getCOFFLinkerOpts() << '\n';
299
300 if (TT.isOSBinFormatCOFF())
301 outs() << "linker opts: " << Input->getCOFFLinkerOpts() << '\n';
297302
298303 std::vector ComdatTable = Input->getComdatTable();
299304 for (const InputFile::Symbol &Sym : Input->symbols()) {
327332 if (Comdat != -1)
328333 outs() << " comdat " << ComdatTable[Comdat] << '\n';
329334
330 if (Sym.isWeak() && Sym.isIndirect())
335 if (TT.isOSBinFormatCOFF() && Sym.isWeak() && Sym.isIndirect())
331336 outs() << " fallback " << Sym.getCOFFWeakExternalFallback() << '\n';
332337 }
333338