llvm.org GIT mirror llvm / e58bfc9
Move summary creation out of llvm-as into opt Summary: Let keep llvm-as "dumb": it converts textual IR to bitcode. This commit removes the dependency from llvm-as to libLLVMAnalysis. We'll add back summary in llvm-as if we get to a textual representation for it at some point. In the meantime, opt seems like a better place for that. Reviewers: tejohnson Subscribers: joker.eph, llvm-commits Differential Revision: http://reviews.llvm.org/D19032 From: Mehdi Amini <mehdi.amini@apple.com> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@266131 91177308-0d34-0410-b5e6-96231b3b80d8 Mehdi Amini 3 years ago
26 changed file(s) with 55 addition(s) and 59 deletion(s). Raw diff Collapse all Expand all
564564 }
565565
566566 /// setOptLevel - Set the optimization level for the JIT. This option
567 /// defaults to CodeGenOpt::Default.
567 /// defaults to CodeGenOpt::Default.-
568568 EngineBuilder &setOptLevel(CodeGenOpt::Level l) {
569569 OptLevel = l;
570570 return *this;
0 ; Check per module hash.
1 ; RUN: llvm-as -module-hash %s -o - | llvm-bcanalyzer -dump | FileCheck %s --check-prefix=MOD1
1 ; RUN: opt -module-hash %s -o - | llvm-bcanalyzer -dump | FileCheck %s --check-prefix=MOD1
22 ; MOD1:
3 ; RUN: llvm-as -module-hash %p/Inputs/module_hash.ll -o - | llvm-bcanalyzer -dump | FileCheck %s --check-prefix=MOD2
3 ; RUN: opt -module-hash %p/Inputs/module_hash.ll -o - | llvm-bcanalyzer -dump | FileCheck %s --check-prefix=MOD2
44 ; MOD2:
55
66 ; Check that the hash matches in the combined index.
77
88 ; First regenerate the modules with a summary
9 ; RUN: llvm-as -module-hash -module-summary %s -o %t.m1.bc
10 ; RUN: llvm-as -module-hash -module-summary %p/Inputs/module_hash.ll -o %t.m2.bc
9 ; RUN: opt -module-hash -module-summary %s -o %t.m1.bc
10 ; RUN: opt -module-hash -module-summary %p/Inputs/module_hash.ll -o %t.m2.bc
1111
1212 ; Recover the hashes from the modules themselves.
1313 ; RUN: llvm-bcanalyzer -dump %t.m1.bc | grep ' %t.hash
0 ; Test to check the callgraph in summary when there is PGO
1 ; RUN: llvm-as -module-summary %s -o %t.o
1 ; RUN: opt -module-summary %s -o %t.o
22 ; RUN: llvm-bcanalyzer -dump %t.o | FileCheck %s
3 ; RUN: llvm-as -module-summary %p/Inputs/thinlto-function-summary-callgraph.ll -o %t2.o
3 ; RUN: opt -module-summary %p/Inputs/thinlto-function-summary-callgraph.ll -o %t2.o
44 ; RUN: llvm-lto -thinlto -o %t3 %t.o %t2.o
55 ; RUN: llvm-bcanalyzer -dump %t3.thinlto.bc | FileCheck %s --check-prefix=COMBINED
66
0 ; Test to check the callgraph in summary
1 ; RUN: llvm-as -module-summary %s -o %t.o
1 ; RUN: opt -module-summary %s -o %t.o
22 ; RUN: llvm-bcanalyzer -dump %t.o | FileCheck %s
3 ; RUN: llvm-as -module-summary %p/Inputs/thinlto-function-summary-callgraph.ll -o %t2.o
3 ; RUN: opt -module-summary %p/Inputs/thinlto-function-summary-callgraph.ll -o %t2.o
44 ; RUN: llvm-lto -thinlto -o %t3 %t.o %t2.o
55 ; RUN: llvm-bcanalyzer -dump %t3.thinlto.bc | FileCheck %s --check-prefix=COMBINED
66
0 ; Test to check both the callgraph and refgraph in summary
1 ; RUN: llvm-as -module-summary %s -o %t.o
1 ; RUN: opt -module-summary %s -o %t.o
22 ; RUN: llvm-bcanalyzer -dump %t.o | FileCheck %s
33
44 ; See if the calls and other references are recorded properly using the
None ; RUN: llvm-as -module-summary < %s | llvm-bcanalyzer -dump | FileCheck %s -check-prefix=BC
0 ; RUN: opt -module-summary < %s | llvm-bcanalyzer -dump | FileCheck %s -check-prefix=BC
11 ; Check for summary block/records.
22
33 ; Check the value ids in the summary entries against the
1212 ; BC-NEXT: record string = 'bar'
1313 ; BC-NEXT: record string = 'f'
1414
15 ; RUN: llvm-as -module-summary < %s | llvm-dis | FileCheck %s
15 ; RUN: opt -module-summary < %s | llvm-dis | FileCheck %s
1616 ; Check that this round-trips correctly.
1717
1818 ; ModuleID = ''
0 ; Check the linkage types in both the per-module and combined summaries.
1 ; RUN: llvm-as -module-summary %s -o %t.o
1 ; RUN: opt -module-summary %s -o %t.o
22 ; RUN: llvm-bcanalyzer -dump %t.o | FileCheck %s
33 ; RUN: llvm-lto -thinlto -o %t2 %t.o
44 ; RUN: llvm-bcanalyzer -dump %t2.thinlto.bc | FileCheck %s --check-prefix=COMBINED
0 ; First ensure that the ThinLTO handling in llvm-link and llvm-lto handles
11 ; bitcode without summary sections gracefully.
2 ; RUN: llvm-as %s -o %t.bc
3 ; RUN: llvm-as %p/Inputs/funcimport.ll -o %t2.bc
2 ; RUN: opt %s -o %t.bc
3 ; RUN: opt %p/Inputs/funcimport.ll -o %t2.bc
44 ; RUN: llvm-link %t.bc -summary-index=%t.bc -S
55 ; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc
66
77 ; Do setup work for all below tests: generate bitcode and combined index
8 ; RUN: llvm-as -module-summary %s -o %t.bc
9 ; RUN: llvm-as -module-summary %p/Inputs/funcimport.ll -o %t2.bc
8 ; RUN: opt -module-summary %s -o %t.bc
9 ; RUN: opt -module-summary %p/Inputs/funcimport.ll -o %t2.bc
1010 ; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc
1111
1212 ; Ensure statics are promoted/renamed correctly from this file (all but
None ; RUN: llvm-as -module-summary %s -o %t1.bc
1 ; RUN: llvm-as -module-summary %p/Inputs/funcimport2.ll -o %t2.bc
0 ; RUN: opt -module-summary %s -o %t1.bc
1 ; RUN: opt -module-summary %p/Inputs/funcimport2.ll -o %t2.bc
22 ; RUN: llvm-lto -thinlto -o %t3 %t1.bc %t2.bc
33 ; RUN: llvm-link -import=bar:%t2.bc %t1.bc -summary-index=%t3.thinlto.bc -S | FileCheck %s
44
None ; RUN: llvm-as -module-summary %s -o %t.bc
1 ; RUN: llvm-as -module-summary %p/Inputs/funcimport_appending_global.ll -o %t2.bc
0 ; RUN: opt -module-summary %s -o %t.bc
1 ; RUN: opt -module-summary %p/Inputs/funcimport_appending_global.ll -o %t2.bc
22 ; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc
33
44 ; Do the import now
0 ; Do setup work for all below tests: generate bitcode and combined index
1 ; RUN: llvm-as -module-summary %s -o %t.bc
2 ; RUN: llvm-as -module-summary %p/Inputs/funcimport_comdat.ll -o %t2.bc
1 ; RUN: opt -module-summary %s -o %t.bc
2 ; RUN: opt -module-summary %p/Inputs/funcimport_comdat.ll -o %t2.bc
33 ; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc
44
55 ; Ensure linking of comdat containing external linkage global and function
0 ; Do setup work for all below tests: generate bitcode and combined index
1 ; RUN: llvm-as -module-summary %s -o %t.bc
2 ; RUN: llvm-as -module-summary %p/Inputs/thinlto_funcimport_debug.ll -o %t2.bc
1 ; RUN: opt -module-summary %s -o %t.bc
2 ; RUN: opt -module-summary %p/Inputs/thinlto_funcimport_debug.ll -o %t2.bc
33 ; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc
44
55 ; If we import func1 and not func2 we should only link DISubprogram for func1
0 ; Do setup work for all below tests: generate bitcode and combined index
1 ; RUN: llvm-as -module-summary %s -o %t.bc
2 ; RUN: llvm-as -module-summary %p/Inputs/funcimport.ll -o %t2.bc
1 ; RUN: opt -module-summary %s -o %t.bc
2 ; RUN: opt -module-summary %p/Inputs/funcimport.ll -o %t2.bc
33 ; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc
44
55 ; Ensure statics are promoted/renamed correctly from this file (all but
0 ; Do setup work for all below tests: generate bitcode and combined index
1 ; RUN: llvm-as -module-summary %s -o %t.bc
2 ; RUN: llvm-as -module-summary %p/Inputs/odr_resolution.ll -o %t2.bc
1 ; RUN: opt -module-summary %s -o %t.bc
2 ; RUN: opt -module-summary %p/Inputs/odr_resolution.ll -o %t2.bc
33 ; RUN: llvm-lto -thinlto-action=thinlink -o %t3.bc %t.bc %t2.bc
44
55 ; Verify that only one ODR is selected across modules, but non ODR are not affected.
0 ; Do setup work for all below tests: generate bitcode and combined index
1 ; RUN: llvm-as -module-summary %s -o %t.bc
2 ; RUN: llvm-as -module-summary %p/Inputs/adjustable_threshold.ll -o %t2.bc
1 ; RUN: opt -module-summary %s -o %t.bc
2 ; RUN: opt -module-summary %p/Inputs/adjustable_threshold.ll -o %t2.bc
33 ; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc
44
55 ; Test import with default progressive instruction factor
0 ; Do setup work for all below tests: generate bitcode and combined index
1 ; RUN: llvm-as -module-summary %s -o %t.bc
2 ; RUN: llvm-as -module-summary %p/Inputs/funcimport.ll -o %t2.bc
1 ; RUN: opt -module-summary %s -o %t.bc
2 ; RUN: opt -module-summary %p/Inputs/funcimport.ll -o %t2.bc
33 ; RUN: llvm-lto -thinlto -print-summary-global-ids -o %t3 %t.bc %t2.bc 2>&1 | FileCheck %s --check-prefix=GUID
44
55 ; Do the import now
0 ; Do setup work for all below tests: generate bitcode and combined index
1 ; RUN: llvm-as -module-summary %s -o %t.bc
2 ; RUN: llvm-as -module-summary %p/Inputs/funcimport_alias.ll -o %t2.bc
1 ; RUN: opt -module-summary %s -o %t.bc
2 ; RUN: opt -module-summary %p/Inputs/funcimport_alias.ll -o %t2.bc
33 ; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc
44
55 ; Do the import now. Ensures that the importer handles an external call
0 ; Do setup work for all below tests: generate bitcode and combined index
1 ; RUN: llvm-as -module-summary %s -o %t.bc
2 ; RUN: llvm-as -module-summary %p/Inputs/funcimport_debug.ll -o %t2.bc
1 ; RUN: opt -module-summary %s -o %t.bc
2 ; RUN: opt -module-summary %p/Inputs/funcimport_debug.ll -o %t2.bc
33 ; RUN: llvm-lto -thinlto -o %t3 %t.bc %t2.bc
44
55 ; Do the import now and confirm that metadata is linked for imported function.
0 ; RUN: llc %s -o %t.o -filetype=obj -relocation-model=pic
1 ; RUN: llvm-as -module-summary %p/Inputs/pr19901-1.ll -o %t2.o
1 ; RUN: opt -module-summary %p/Inputs/pr19901-1.ll -o %t2.o
22 ; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
33 ; RUN: --plugin-opt=thinlto \
44 ; RUN: -shared -m elf_x86_64 -o %t.so %t2.o %t.o
1212 ; RUN: llvm-nm %t4 | FileCheck %s --check-prefix=NM
1313
1414 ; Next generate summary sections and test gold handling.
15 ; RUN: llvm-as -module-summary %s -o %t.o
16 ; RUN: llvm-as -module-summary %p/Inputs/thinlto.ll -o %t2.o
15 ; RUN: opt -module-summary %s -o %t.o
16 ; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.o
1717
1818 ; Ensure gold generates an index and not a binary if requested.
1919 ; RUN: %gold -plugin %llvmshlibdir/LLVMgold.so \
None ; RUN: llvm-as -module-summary %s -o %t.o
1 ; RUN: llvm-as -module-summary %p/Inputs/thinlto_linkonceresolution.ll -o %t2.o
0 ; RUN: opt -module-summary %s -o %t.o
1 ; RUN: opt -module-summary %p/Inputs/thinlto_linkonceresolution.ll -o %t2.o
22
33 ; Ensure the plugin ensures that for ThinLTO the prevailing copy of a
44 ; linkonce symbol is changed to weak to ensure it is not eliminated.
0 ; Test combined function index generation for ThinLTO via llvm-lto.
1 ; RUN: llvm-as -module-summary %s -o %t.o
2 ; RUN: llvm-as -module-summary %p/Inputs/thinlto.ll -o %t2.o
1 ; RUN: opt -module-summary %s -o %t.o
2 ; RUN: opt -module-summary %p/Inputs/thinlto.ll -o %t2.o
33 ; RUN: llvm-lto -thinlto -o %t3 %t.o %t2.o
44 ; RUN: llvm-bcanalyzer -dump %t3.thinlto.bc | FileCheck %s --check-prefix=COMBINED
55 ; RUN: not test -e %t3
0 set(LLVM_LINK_COMPONENTS
1 Analysis
21 AsmParser
32 BitWriter
43 Core
1818 type = Tool
1919 name = llvm-as
2020 parent = Tools
21 required_libraries = Analysis AsmParser BitWriter
21 required_libraries = AsmParser BitWriter
1414 //
1515 //===----------------------------------------------------------------------===//
1616
17 #include "llvm/Analysis/ModuleSummaryAnalysis.h"
1817 #include "llvm/AsmParser/Parser.h"
1918 #include "llvm/Bitcode/ReaderWriter.h"
2019 #include "llvm/IR/LLVMContext.h"
4342
4443 static cl::opt DisableOutput("disable-output", cl::desc("Disable output"),
4544 cl::init(false));
46
47 static cl::opt EmitSummaryIndex("module-summary",
48 cl::desc("Emit module summary index"),
49 cl::init(false));
5045
5146 static cl::opt EmitModuleHash("module-hash", cl::desc("Emit module hash"),
5247 cl::init(false));
8378 exit(1);
8479 }
8580
86 if (Force || !CheckBitcodeOutputToConsole(Out->os(), true)) {
87 std::unique_ptr Index;
88 if (EmitSummaryIndex)
89 Index = ModuleSummaryIndexBuilder(M).takeIndex();
90
91 WriteBitcodeToFile(M, Out->os(), PreserveBitcodeUseListOrder, Index.get(),
81 if (Force || !CheckBitcodeOutputToConsole(Out->os(), true))
82 WriteBitcodeToFile(M, Out->os(), PreserveBitcodeUseListOrder, nullptr,
9283 EmitModuleHash);
93 }
9484
9585 // Declare success.
9686 Out->keep();
157157 cl::desc("Disable the slp vectorization pass"),
158158 cl::init(false));
159159
160 static cl::opt EmitSummaryIndex("module-summary",
161 cl::desc("Emit module summary index"),
162 cl::init(false));
163
164 static cl::opt EmitModuleHash("module-hash", cl::desc("Emit module hash"),
165 cl::init(false));
160166
161167 static cl::opt
162168 DisableSimplifyLibCalls("disable-simplify-libcalls",
616622 if (OutputAssembly)
617623 Passes.add(createPrintModulePass(*OS, "", PreserveAssemblyUseListOrder));
618624 else
619 Passes.add(createBitcodeWriterPass(*OS, PreserveBitcodeUseListOrder));
625 Passes.add(createBitcodeWriterPass(*OS, PreserveBitcodeUseListOrder,
626 EmitSummaryIndex, EmitModuleHash));
620627 }
621628
622629 // Before executing passes, print the final values of the LLVM options.