Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[lld] Support --lto-emit-asm and --plugin-opt=emit-asm
Summary: The switch --plugin-opt=emit-asm can be used with the gold linker to dump the final assembly code generated by LTO in a user-friendly way. Unfortunately it doesn't work with lld. I'm hooking it up with lld. With that switch, lld emits assembly code into the output file (specified by -o) and if there are multiple input files, each of their assembly code will be emitted into a separate file named by suffixing the output file name with a unique number, respectively. The linking then stops after generating those assembly files. Reviewers: espindola, wenlei, tejohnson, MaskRay, grimar Reviewed By: tejohnson, MaskRay, grimar Subscribers: pcc, emaste, inglorion, arichardson, hiraditya, MaskRay, steven_wu, dexonsmith, llvm-commits Tags: #llvm Differential Revision: https://reviews.llvm.org/D77231
- Loading branch information
Showing
5 changed files
with
44 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
; REQUIRES: x86 | ||
; RUN: llvm-as %s -o %t.o | ||
; RUN: ld.lld --lto-emit-asm -shared %t.o -o - | FileCheck %s | ||
; RUN: ld.lld --plugin-opt=emit-asm --plugin-opt=lto-partitions=2 -shared %t.o -o %t2.s | ||
; RUN: cat %t2.s %t2.s1 | FileCheck %s | ||
|
||
; RUN: ld.lld --lto-emit-asm --save-temps -shared %t.o -o %t3.s | ||
; RUN: FileCheck --input-file %t3.s %s | ||
; RUN: llvm-dis %t3.s.0.4.opt.bc -o - | FileCheck --check-prefix=OPT %s | ||
|
||
target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128" | ||
target triple = "x86_64-unknown-linux-gnu" | ||
|
||
; CHECK-DAG: f1: | ||
; OPT-DAG: define void @f1() | ||
define void @f1() { | ||
ret void | ||
} | ||
|
||
; CHECK-DAG: f2: | ||
; OPT-DAG: define void @f2() | ||
define void @f2() { | ||
ret void | ||
} |