1# RUN: yaml2obj < %s > %t.obj
2# RUN: lld-link /opt:icf /entry:foo /out:%t.exe /subsystem:console /include:bar \
3# RUN:   /verbose %t.obj > %t.log 2>&1
4# RUN: FileCheck -check-prefix=ICF %s < %t.log
5
6# ICF: Selected foo
7# ICF:   Removed bar
8
9# RUN: lld-link /entry:foo /out:%t.exe /subsystem:console /include:bar \
10# RUN:   /verbose /opt:noicf %t.obj > %t.log 2>&1
11# RUN: FileCheck -check-prefix=NOICF %s < %t.log
12# RUN: lld-link /entry:foo /out:%t.exe /subsystem:console /include:bar \
13# RUN:   /verbose /opt:noref,noicf %t.obj > %t.log 2>&1
14# RUN: FileCheck -check-prefix=NOICF %s < %t.log
15
16# ICF is on by default (no /opt: flags).
17# RUN: lld-link /entry:foo /out:%t.exe /subsystem:console \
18# RUN:   /include:bar /verbose %t.obj > %t.log 2>&1
19# RUN: FileCheck -check-prefix=ICF %s < %t.log
20
21# /debug disables ICF.
22# RUN: lld-link /debug /entry:foo /out:%t.exe /subsystem:console \
23# RUN:   /include:bar /verbose %t.obj > %t.log 2>&1
24# RUN: FileCheck -check-prefix=NOICF %s < %t.log
25
26# /profile disables ICF.
27# RUN: lld-link /profile /entry:foo /out:%t.exe /subsystem:console \
28# RUN:   /include:bar /verbose %t.obj > %t.log 2>&1
29# RUN: FileCheck -check-prefix=NOICF %s < %t.log
30
31# /opt:noref disables ICF.
32# RUN: lld-link /opt:noref /entry:foo /out:%t.exe /subsystem:console \
33# RUN:   /include:bar /verbose %t.obj > %t.log 2>&1
34# RUN: FileCheck -check-prefix=NOICF %s < %t.log
35
36# /debug /opt:ref enables ICF.
37# RUN: lld-link /debug /opt:ref /entry:foo /out:%t.exe /subsystem:console \
38# RUN:   /include:bar /verbose %t.obj > %t.log 2>&1
39# RUN: FileCheck -check-prefix=ICF %s < %t.log
40
41# /debug /opt:noicf,ref disables ICF.
42# RUN: lld-link /debug /opt:noicf,ref /entry:foo /out:%t.exe /subsystem:console \
43# RUN:   /include:bar /verbose %t.obj > %t.log 2>&1
44# RUN: FileCheck -check-prefix=NOICF %s < %t.log
45
46# NOICF-NOT: Removed foo
47# NOICF-NOT: Removed bar
48
49--- !COFF
50header:
51  Machine:         IMAGE_FILE_MACHINE_AMD64
52  Characteristics: []
53sections:
54  - Name:            '.text$mn'
55    Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
56    Alignment:       16
57    SectionData:     4883EC28E8000000004883C428C3
58  - Name:            '.text$mn'
59    Characteristics: [ IMAGE_SCN_CNT_CODE, IMAGE_SCN_LNK_COMDAT, IMAGE_SCN_MEM_EXECUTE, IMAGE_SCN_MEM_READ ]
60    Alignment:       16
61    SectionData:     4883EC28E8000000004883C428C3
62symbols:
63  - Name:            '.text$mn'
64    Value:           0
65    SectionNumber:   1
66    SimpleType:      IMAGE_SYM_TYPE_NULL
67    ComplexType:     IMAGE_SYM_DTYPE_NULL
68    StorageClass:    IMAGE_SYM_CLASS_STATIC
69    SectionDefinition:
70      Length:          14
71      NumberOfRelocations: 0
72      NumberOfLinenumbers: 0
73      CheckSum:        1682752513
74      Number:          0
75      Selection:       IMAGE_COMDAT_SELECT_NODUPLICATES
76  - Name:            '.text$mn'
77    Value:           0
78    SectionNumber:   2
79    SimpleType:      IMAGE_SYM_TYPE_NULL
80    ComplexType:     IMAGE_SYM_DTYPE_NULL
81    StorageClass:    IMAGE_SYM_CLASS_STATIC
82    SectionDefinition:
83      Length:          14
84      NumberOfRelocations: 0
85      NumberOfLinenumbers: 0
86      CheckSum:        1682752513
87      Number:          0
88      Selection:       IMAGE_COMDAT_SELECT_NODUPLICATES
89  - Name:            foo
90    Value:           0
91    SectionNumber:   1
92    SimpleType:      IMAGE_SYM_TYPE_NULL
93    ComplexType:     IMAGE_SYM_DTYPE_FUNCTION
94    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
95  - Name:            bar
96    Value:           0
97    SectionNumber:   2
98    SimpleType:      IMAGE_SYM_TYPE_NULL
99    ComplexType:     IMAGE_SYM_DTYPE_FUNCTION
100    StorageClass:    IMAGE_SYM_CLASS_EXTERNAL
101...
102