1# REQUIRES: x86 2 3# RUN: llvm-mc -filetype=obj -triple=x86_64 %s -o %t.o 4# RUN: ld.lld -pie %t.o --icf=all --print-icf-sections -o /dev/null | \ 5# RUN: FileCheck --check-prefixes=EXE %s 6 7# RUN: ld.lld -shared %t.o --icf=all --print-icf-sections -o /dev/null | \ 8# RUN: FileCheck --check-prefix=DSO %s 9 10## Definitions are non-preemptible in an executable. 11# EXE-NOT: {{.}} 12# EXE: selected section {{.*}}:(.text.g1) 13# EXE-NEXT: removing identical section {{.*}}:(.text.g2) 14# EXE-NEXT: removing identical section {{.*}}:(.text.g3) 15# EXE-NEXT: selected section {{.*}}:(.text.f1) 16# EXE-NEXT: removing identical section {{.*}}:(.text.f2) 17# EXE-NEXT: selected section {{.*}}:(.text.h1) 18# EXE-NEXT: removing identical section {{.*}}:(.text.h2) 19# EXE-NEXT: removing identical section {{.*}}:(.text.h3) 20# EXE-NOT: {{.}} 21 22## Definitions are preemptible in a DSO. Only leaf functions can be folded. 23# DSO-NOT: {{.}} 24# DSO: selected section {{.*}}:(.text.g1) 25# DSO-NEXT: removing identical section {{.*}}:(.text.g3) 26# DSO-NEXT: selected section {{.*}}:(.text.f1) 27# DSO-NEXT: removing identical section {{.*}}:(.text.f2) 28# DSO-NOT: {{.}} 29 30.globl _start, f1, f2, g1, g2, g3 31_start: 32 33.section .text.f1 34f1: ret 35.section .text.f2 36f2: ret 37 38## In -shared mode, .text.g1 and .text.g2 cannot be folded because f1 and f2 are 39## preemptible and may refer to different functions at runtime. 40.section .text.g1 41g1: jmp f1@plt 42.section .text.g2 43g2: jmp f2@plt 44.section .text.g3 45g3: jmp f1@plt 46 47## In -shared mode, the sections below cannot be folded because g1, g2 and g3 48## are preemptible and may refer to different functions at runtime. 49.section .text.h1 50jmp g1@plt 51.section .text.h2 52jmp g2@plt 53.section .text.h3 54jmp g3@plt 55