139 lines · plain
1; Test that global values with the same specified section produces multiple2; sections with different sets of flags, depending on the properties (mutable,3; executable) of the global value.4 5; RUN: llc < %s | FileCheck %s6; RUN: llc -function-sections < %s | FileCheck %s --check-prefix=CHECK --check-prefix=FNSECTIONS7target triple="x86_64-unknown-unknown-elf"8 9; Normal function goes in .text, or in it's own named section with -function-sections.10define i32 @fn_text() {11 entry:12 ret i32 013}14; FNSECTIONS: .section .text.fn_text,"ax",@progbits{{$}}15; CHECK: .globl fn_text16; CHECK: fn_text:17 18; A second function placed in .text, to check the behaviour with -function-sections.19; It should be emitted to a new section with a new name, not expected to require unique.20define i32 @fn_text2() {21 entry:22 ret i32 023}24; FNSECTIONS: .section .text.fn_text2,"ax",@progbits{{$}}25; CHECK: .globl fn_text226; CHECK: fn_text2:27 28; Functions in user defined executable sections29define i32 @fn_s1() section "s1" {30 entry:31 ret i32 032}33; CHECK: .section s1,"ax",@progbits{{$}}34; CHECK-NEXT: .globl fn_s135; CHECK: fn_s1:36 37define i32 @fn_s2() section "s2" {38 entry:39 ret i32 040}41; CHECK: .section s2,"ax",@progbits{{$}}42; CHECK-NEXT: .globl fn_s243; CHECK: fn_s2:44 45; A second function in s2 should share the same .section46define i32 @fn2_s2() section "s2" {47 entry:48 ret i32 049}50; CHECK-NOT: .section51; CHECK: .globl fn2_s252; CHECK: fn2_s2:53 54; Values that share a section name with a function are placed in different sections without executable flag55@rw_s1 = global i32 10, section "s1", align 456@ro_s2 = constant i32 10, section "s2", align 457; CHECK: .section s1,"aw",@progbits,unique,[[#UNIQUE_S1_aw:]]58; CHECK-NEXT: .globl rw_s159; CHECK: rw_s1:60; CHECK: .section s2,"a",@progbits,unique,[[#UNIQUE_S2_a:]]61; CHECK-NEXT: .globl ro_s262; CHECK: ro_s2:63 64; Placing another value in the same section with the same flags uses the same unique ID65@rw2_s1 = global i32 10, section "s1", align 466@ro2_s2 = constant i32 10, section "s2", align 467; CHECK: .section s1,"aw",@progbits,unique,[[#UNIQUE_S1_aw]]68; CHECK-NEXT: .globl rw2_s169; CHECK: rw2_s1:70; CHECK: .section s2,"a",@progbits,unique,[[#UNIQUE_S2_a]]71; CHECK-NEXT: .globl ro2_s272; CHECK: ro2_s2:73 74; Normal user defined section, first is the generic section, second should be unique75@ro_s3 = constant i32 10, section "s3", align 476@rw_s3 = global i32 10, section "s3", align 477; CHECK: .section s3,"a",@progbits{{$}}78; CHECK-NEXT: .globl ro_s379; CHECK: ro_s3:80; CHECK: .section s3,"aw",@progbits,unique,[[#U:]]81; CHECK-NEXT: .globl rw_s382; CHECK: rw_s3:83 84; Values declared without explicit sections go into compatible default sections and don't require unique85@rw_nosec = global i32 10, align 486@ro_nosec = constant i32 10, align 487; CHECK: .data{{$}}88; CHECK-NEXT: .globl rw_nosec89; CHECK: rw_nosec:90; CHECK: .section .rodata,"a",@progbits{{$}}91; CHECK-NEXT: .globl ro_nosec92; CHECK: ro_nosec:93 94; Explicitly placed in .rodata with writeable set. The writable section should be uniqued, not the default ro section, even if it comes first.95@rw_rodata = global [2 x i32] zeroinitializer, section ".rodata", align 496@ro_rodata = constant [2 x i32] zeroinitializer, section ".rodata", align 497; CHECK: .section .rodata,"aw",@progbits,unique,[[#U+1]]{{$}}98; CHECK-NEXT: .globl rw_rodata{{$}}99; CHECK: rw_rodata:100; CHECK: .section .rodata,"a",@progbits{{$}}101; CHECK-NEXT: .globl ro_rodata{{$}}102; CHECK: ro_rodata:103 104; Writable symbols in writable default sections; no need to unique105@w_sdata = global [4 x i32] zeroinitializer, section ".sdata", align 4106@w_sbss = global [4 x i32] zeroinitializer, section ".sbss", align 4107; CHECK: .section .sdata,"aw",@progbits{{$}}108; CHECK-NEXT: .globl w_sdata{{$}}109; CHECK: w_sdata:110; CHECK: .section .sbss,"aw",@nobits{{$}}111; CHECK-NEXT: .globl w_sbss{{$}}112; CHECK: w_sbss:113 114; Multiple .text sections are emitted for read-only and read-write sections using .text name.115@rw_text = global i32 10, section ".text", align 4116@ro_text = constant i32 10, section ".text", align 4117; CHECK: .section .text,"aw",@progbits,unique,[[#U+2]]118; CHECK-NEXT: .globl rw_text119; CHECK: rw_text:120; CHECK: .section .text,"a",@progbits,unique,[[#U+3]]121; CHECK-NEXT: .globl ro_text122; CHECK: ro_text:123 124; A read-only .data section is emitted125@ro_data = constant i32 10, section ".data", align 4126; CHECK: .section .data,"a",@progbits,unique,[[#U+4]]127; CHECK-NEXT: .globl ro_data128; CHECK: ro_data:129 130; TLS and non-TLS symbols cannot live in the same section131@tls_var = thread_local global i32 10, section "s4", align 4132@non_tls_var = global i32 10, section "s4", align 4133; CHECK: .section s4,"awT",@progbits{{$}}134; CHECK-NEXT: .globl tls_var135; CHECK: tls_var:136; CHECK: .section s4,"aw",@progbits,unique,[[#U+5]]137; CHECK-NEXT: .globl non_tls_var138; CHECK: non_tls_var:139