llvm-project/lld/test/ELF/lto/parallel-internalize.ll
Fangrui Song f7669ba3d9
[ELF] --save-temps --lto-emit-asm: derive ELF/asm file names from bitcode file names
Port COFF's https://reviews.llvm.org/D78221 and
https://reviews.llvm.org/D137217 to ELF. For the in-process ThinLTO
link, `ld.lld --save-temps a.o d/b.o -o out` will create
ELF relocatable files `out.lto.a.o`/`d/out.lto.b.o` instead of
`out1.lto.o`/`out2.lto.o`. Deriving the LTO-generated relocatable file
name from bitcode file names helps debugging.

The relocatable file name from the first regular LTO partition does not
change: `out.lto.o`. The second, if present due to `--lto-partition=`,
changes from `out1.lto.o` to `lto.1.o`.

For an archive member, e.g. `d/a.a(coll.o at 8)`,
the relocatable file is `d/out.lto.a.a(coll.o at 8).o`.

`--lto-emit-asm` file names are changed similarly. `--lto-emit-asm -o
out` now creates `out.lto.s` instead of `out`, therefore the
`--lto-emit-asm -o -` idiom no longer works. However, I think this new
behavior (which matches COFF) is better since keeping or removing
`--lto-emit-asm` will dump different files, instead of overwriting the
`-o` output file from an executable/shared object to an assembly file.

Reviewers: rnk, igorkudrin, xur-llvm, teresajohnson, ZequanWu

Reviewed By: teresajohnson

Pull Request: https://github.com/llvm/llvm-project/pull/78835
2024-01-23 11:38:15 -08:00

77 lines
2.1 KiB
LLVM

; REQUIRES: x86
; RUN: rm -rf %t && mkdir %t && cd %t
; RUN: llvm-as -o a.bc %s
; RUN: ld.lld --lto-partitions=2 -save-temps -o out a.bc -e foo --lto-O0
; RUN: llvm-readobj --symbols --dyn-syms out | FileCheck %s
; RUN: llvm-nm out.lto.o | FileCheck --check-prefix=CHECK0 %s
; RUN: llvm-nm out.lto.1.o | FileCheck --check-prefix=CHECK1 %s
; CHECK: Symbols [
; CHECK-NEXT: Symbol {
; CHECK-NEXT: Name: (0)
; CHECK-NEXT: Value: 0x0
; CHECK-NEXT: Size: 0
; CHECK-NEXT: Binding: Local (0x0)
; CHECK-NEXT: Type: None (0x0)
; CHECK-NEXT: Other: 0
; CHECK-NEXT: Section: Undefined (0x0)
; CHECK-NEXT: }
; CHECK-NEXT: Symbol {
; CHECK-NEXT: Name: {{.*}}.o
; CHECK-NEXT: Value: 0x0
; CHECK-NEXT: Size: 0
; CHECK-NEXT: Binding: Local
; CHECK-NEXT: Type: File
; CHECK-NEXT: Other: 0
; CHECK-NEXT: Section: Absolute
; CHECK-NEXT: }
; CHECK-NEXT: Symbol {
; CHECK-NEXT: Name: {{.*}}.o
; CHECK-NEXT: Value: 0x0
; CHECK-NEXT: Size: 0
; CHECK-NEXT: Binding: Local
; CHECK-NEXT: Type: File
; CHECK-NEXT: Other: 0
; CHECK-NEXT: Section: Absolute
; CHECK-NEXT: }
; CHECK-NEXT: Symbol {
; CHECK-NEXT: Name: bar
; CHECK-NEXT: Value:
; CHECK-NEXT: Size: 8
; CHECK-NEXT: Binding: Local (0x0)
; CHECK-NEXT: Type: Function (0x2)
; CHECK-NEXT: Other [ (0x2)
; CHECK-NEXT: STV_HIDDEN (0x2)
; CHECK-NEXT: ]
; CHECK-NEXT: Section: .text (0x2)
; CHECK-NEXT: }
; CHECK-NEXT: Symbol {
; CHECK-NEXT: Name: foo
; CHECK-NEXT: Value:
; CHECK-NEXT: Size: 8
; CHECK-NEXT: Binding: Global (0x1)
; CHECK-NEXT: Type: Function (0x2)
; CHECK-NEXT: Other: 0
; CHECK-NEXT: Section: .text (0x2)
; CHECK-NEXT: }
; CHECK-NEXT: ]
; CHECK-NEXT: DynamicSymbols [
; CHECK-NEXT: ]
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"
; CHECK0: U bar
; CHECK0: T foo
define void @foo() {
call void @bar()
ret void
}
; CHECK1: T bar
; CHECK1: U foo
define void @bar() {
call void @foo()
ret void
}