2 ; RUN: llvm-as -o %T/comdat-main.lto.obj %s
3 ; RUN: llvm-as -o %T/comdat1.lto.obj %S/Inputs/lto-comdat1.ll
4 ; RUN: llvm-as -o %T/comdat2.lto.obj %S/Inputs/lto-comdat2.ll
5 ; RUN: rm -f %T/comdat.lto.lib
6 ; RUN: llvm-ar cru %T/comdat.lto.lib %T/comdat1.lto.obj %T/comdat2.lto.obj
8 ; RUN: llc -filetype=obj -o %T/comdat-main.obj %s
9 ; RUN: llc -filetype=obj -o %T/comdat1.obj %S/Inputs/lto-comdat1.ll
10 ; RUN: llc -filetype=obj -o %T/comdat2.obj %S/Inputs/lto-comdat2.ll
11 ; RUN: rm -f %T/comdat.lib
12 ; RUN: llvm-ar cru %T/comdat.lib %T/comdat1.obj %T/comdat2.obj
14 ; Check that, when we use an LTO main with LTO objects, we optimize away all
15 ; of f1, f2, and comdat.
16 ; RUN: lld-link /out:%T/comdat-main.exe /entry:main /subsystem:console %T/comdat-main.lto.obj %T/comdat1.lto.obj %T/comdat2.lto.obj
17 ; RUN: llvm-readobj --file-headers %T/comdat-main.exe | FileCheck -check-prefix=HEADERS-11 %s
18 ; RUN: llvm-objdump --no-print-imm-hex -d %T/comdat-main.exe | FileCheck --check-prefix=TEXT-11 %s
19 ; RUN: lld-link /out:%T/comdat-main.exe /entry:main /subsystem:console %T/comdat-main.lto.obj %T/comdat.lto.lib
20 ; RUN: llvm-readobj --file-headers %T/comdat-main.exe | FileCheck -check-prefix=HEADERS-11 %s
21 ; RUN: llvm-objdump --no-print-imm-hex -d %T/comdat-main.exe | FileCheck --check-prefix=TEXT-11 %s
23 ; Check that, when we use a non-LTO main with LTO objects, we pick the comdat
24 ; implementation in LTO, elide calls to it from inside LTO, and retain the
25 ; call to comdat from main.
26 ; RUN: lld-link /out:%T/comdat-main.exe /entry:main /subsystem:console %T/comdat-main.obj %T/comdat1.lto.obj %T/comdat2.lto.obj
27 ; RUN: llvm-readobj --file-headers %T/comdat-main.exe | FileCheck -check-prefix=HEADERS-01 %s
28 ; RUN: llvm-objdump --no-print-imm-hex -d %T/comdat-main.exe | FileCheck --check-prefix=TEXT-01 %s
29 ; RUN: lld-link /out:%T/comdat-main.exe /entry:main /subsystem:console %T/comdat-main.obj %T/comdat.lto.lib
30 ; RUN: llvm-readobj --file-headers %T/comdat-main.exe | FileCheck -check-prefix=HEADERS-01 %s
31 ; RUN: llvm-objdump --no-print-imm-hex -d %T/comdat-main.exe | FileCheck --check-prefix=TEXT-01 %s
33 ; Check that, when we use an LTO main with non-LTO objects, we pick the comdat
34 ; implementation in LTO, elide the call to it from inside LTO, and keep the
35 ; calls to comdat from the non-LTO objects.
36 ; RUN: lld-link /out:%T/comdat-main.exe /entry:main /subsystem:console %T/comdat-main.lto.obj %T/comdat1.obj %T/comdat2.obj
37 ; RUN: llvm-readobj --file-headers %T/comdat-main.exe | FileCheck -check-prefix=HEADERS-10 %s
38 ; RUN: llvm-objdump --no-print-imm-hex -d %T/comdat-main.exe | FileCheck --check-prefix=TEXT-10 %s
39 ; RUN: lld-link /out:%T/comdat-main.exe /entry:main /subsystem:console %T/comdat-main.lto.obj %T/comdat.lib
40 ; RUN: llvm-readobj --file-headers %T/comdat-main.exe | FileCheck -check-prefix=HEADERS-10 %s
41 ; RUN: llvm-objdump --no-print-imm-hex -d %T/comdat-main.exe | FileCheck --check-prefix=TEXT-10 %s
43 ; HEADERS-11: AddressOfEntryPoint: 0x1000
44 ; TEXT-11: Disassembly of section .text:
46 ; TEXT-11-NEXT: <.text>:
47 ; TEXT-11-NEXT: xorl %eax, %eax
50 ; HEADERS-01: AddressOfEntryPoint: 0x1000
51 ; TEXT-01: Disassembly of section .text:
53 ; TEXT-01-NEXT: <.text>:
54 ; TEXT-01-NEXT: subq $40, %rsp
55 ; TEXT-01-NEXT: callq 0x140001020
56 ; TEXT-01-NEXT: callq 0x140001020
57 ; TEXT-01-NEXT: callq 0x140001020
58 ; TEXT-01-NEXT: xorl %eax, %eax
59 ; TEXT-01-NEXT: addq $40, %rsp
68 ; HEADERS-10: AddressOfEntryPoint: 0x1020
69 ; TEXT-10: Disassembly of section .text:
71 ; TEXT-10-NEXT: <.text>:
72 ; TEXT-10-NEXT: subq $40, %rsp
73 ; TEXT-10-NEXT: callq 0x140001040
75 ; TEXT-10-NEXT: addq $40, %rsp
78 ; TEXT-10-NEXT: subq $40, %rsp
79 ; TEXT-10-NEXT: callq 0x140001040
81 ; TEXT-10-NEXT: addq $40, %rsp
84 ; TEXT-10-NEXT: subq $40, %rsp
85 ; TEXT-10-NEXT: callq 0x140001000
86 ; TEXT-10-NEXT: callq 0x140001010
87 ; TEXT-10-NEXT: xorl %eax, %eax
88 ; TEXT-10-NEXT: addq $40, %rsp
94 target datalayout = "e-m:w-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
95 target triple = "x86_64-pc-windows-msvc"
106 define linkonce_odr void @comdat() comdat {