llvm.org GIT mirror llvm / 02e82c3
[gold] emit assembly listing from gold plugin on LTO stage Summary: Sometimes it's useful to emit assembly after LTO stage to modify it manually. Emitting precodegen bitcode file (via save-temps plugin option) and then feeding it to llc doesn't always give the same binary as original. This patch is simpler alternative to https://reviews.llvm.org/D24020. Patch by Denis Bakhvalov. Reviewers: mehdi_amini, tejohnson Reviewed By: tejohnson Subscribers: MaskRay, inglorion, dexonsmith, llvm-commits Differential Revision: https://reviews.llvm.org/D56114 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@350276 91177308-0d34-0410-b5e6-96231b3b80d8 Teresa Johnson 1 year, 10 months ago
2 changed file(s) with 36 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
0 ; RUN: llvm-as %s -o %t.o
1
2 ; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
3 ; RUN: -m elf_x86_64 --plugin-opt=emit-asm \
4 ; RUN: -shared %t.o -o %t2.s
5 ; RUN: FileCheck --input-file %t2.s %s
6
7 ; RUN: %gold -plugin %llvmshlibdir/LLVMgold%shlibext \
8 ; RUN: -m elf_x86_64 --plugin-opt=emit-asm --plugin-opt=lto-partitions=2\
9 ; RUN: -shared %t.o -o %t2.s
10 ; RUN: cat %t2.s %t2.s1 > %t3.s
11 ; RUN: FileCheck --input-file %t3.s %s
12
13 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
14 target triple = "x86_64-unknown-linux-gnu"
15
16 ; CHECK-DAG: f1:
17 define void @f1() {
18 ret void
19 }
20
21 ; CHECK-DAG: f2:
22 define void @f2() {
23 ret void
24 }
127127 OT_NORMAL,
128128 OT_DISABLE,
129129 OT_BC_ONLY,
130 OT_ASM_ONLY,
130131 OT_SAVE_TEMPS
131132 };
132133 static OutputType TheOutputType = OT_NORMAL;
228229 TheOutputType = OT_SAVE_TEMPS;
229230 } else if (opt == "disable-output") {
230231 TheOutputType = OT_DISABLE;
232 } else if (opt == "emit-asm") {
233 TheOutputType = OT_ASM_ONLY;
231234 } else if (opt == "thinlto") {
232235 thinlto = true;
233236 } else if (opt == "thinlto-index-only") {
881884 check(Conf.addSaveTemps(output_name + ".",
882885 /* UseInputModulePath */ true));
883886 break;
887 case options::OT_ASM_ONLY:
888 Conf.CGFileType = TargetMachine::CGFT_AssemblyFile;
889 break;
884890 }
885891
886892 if (!options::sample_profile.empty())
10081014 Filename = options::obj_path;
10091015 else if (options::TheOutputType == options::OT_SAVE_TEMPS)
10101016 Filename = output_name + ".o";
1017 else if (options::TheOutputType == options::OT_ASM_ONLY)
1018 Filename = output_name;
10111019 bool SaveTemps = !Filename.empty();
10121020
10131021 size_t MaxTasks = Lto->getMaxTasks();
10561064 std::vector, bool>> Files = runLTO();
10571065
10581066 if (options::TheOutputType == options::OT_DISABLE ||
1059 options::TheOutputType == options::OT_BC_ONLY)
1067 options::TheOutputType == options::OT_BC_ONLY ||
1068 options::TheOutputType == options::OT_ASM_ONLY)
10601069 return LDPS_OK;
10611070
10621071 if (options::thinlto_index_only) {
10811090 llvm_shutdown();
10821091
10831092 if (options::TheOutputType == options::OT_BC_ONLY ||
1093 options::TheOutputType == options::OT_ASM_ONLY ||
10841094 options::TheOutputType == options::OT_DISABLE) {
10851095 if (options::TheOutputType == options::OT_DISABLE) {
10861096 // Remove the output file here since ld.bfd creates the output file