llvm.org GIT mirror llvm / 01c2fde
[LTO] Add ability to emit assembly to new LTO API Summary: Add a field to LTO::Config, CGFileType, to select the file type to emit (object or assembly). This is useful for testing and to implement -save-temps. Reviewers: tejohnson, mehdi_amini, pcc Reviewed By: mehdi_amini Subscribers: davide, llvm-commits Differential Revision: https://reviews.llvm.org/D29475 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@295226 91177308-0d34-0410-b5e6-96231b3b80d8 Tobias Edler von Koch 3 years ago
5 changed file(s) with 26 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
1616
1717 #include "llvm/IR/DiagnosticInfo.h"
1818 #include "llvm/Support/CodeGen.h"
19 #include "llvm/Target/TargetMachine.h"
1920 #include "llvm/Target/TargetOptions.h"
2021
2122 #include
4041 Reloc::Model RelocModel = Reloc::PIC_;
4142 CodeModel::Model CodeModel = CodeModel::Default;
4243 CodeGenOpt::Level CGOptLevel = CodeGenOpt::Default;
44 TargetMachine::CodeGenFileType CGFileType = TargetMachine::CGFT_ObjectFile;
4345 unsigned OptLevel = 2;
4446 bool DisableVerify = false;
4547
9797 AddUnsigned(Conf.RelocModel);
9898 AddUnsigned(Conf.CodeModel);
9999 AddUnsigned(Conf.CGOptLevel);
100 AddUnsigned(Conf.CGFileType);
100101 AddUnsigned(Conf.OptLevel);
101102 AddString(Conf.OptPipeline);
102103 AddString(Conf.AAPipeline);
270270
271271 auto Stream = AddStream(Task);
272272 legacy::PassManager CodeGenPasses;
273 if (TM->addPassesToEmitFile(CodeGenPasses, *Stream->OS,
274 TargetMachine::CGFT_ObjectFile))
273 if (TM->addPassesToEmitFile(CodeGenPasses, *Stream->OS, Conf.CGFileType))
275274 report_fatal_error("Failed to setup codegen");
276275 CodeGenPasses.run(Mod);
277276 }
0 ; Test the ability to emit assembly code from the resolution-based LTO API
1 ;
2 ; RUN: llvm-as < %s > %t1.bc
3 ;
4 ; RUN: llvm-lto2 -filetype=asm -r %t1.bc,main,px -o %t2 %t1.bc
5 ; RUN: FileCheck --check-prefix=ASM %s < %t2.0
6 ; RUN: llvm-lto2 -filetype=obj -r %t1.bc,main,px -o %t2 %t1.bc
7 ; RUN: llvm-objdump -d %t2.0 | FileCheck --check-prefix=ASM %s
8 ;
9 ; ASM: main:
10
11 target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
12 target triple = "x86_64-unknown-linux-gnu"
13
14 define i32 @main() {
15 entry:
16 ret i32 23
17 }
18
211211 return 1;
212212 }
213213
214 if (FileType.getNumOccurrences())
215 Conf.CGFileType = FileType;
216
214217 Conf.OverrideTriple = OverrideTriple;
215218 Conf.DefaultTriple = DefaultTriple;
216219