forked from llvm/llvm-project
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Clang] -fseparate-named-sections option (llvm#91028)
When set, the compiler will use separate unique sections for global symbols in named special sections (e.g. symbols that are annotated with __attribute__((section(...)))). Doing so enables linker GC to collect unused symbols without having to use a different section per-symbol.
- Loading branch information
Showing
11 changed files
with
110 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
// REQUIRES: x86-registered-target | ||
|
||
// RUN: %clang_cc1 -triple x86_64-pc-linux -S -o - < %s | FileCheck %s | ||
// RUN: %clang_cc1 -triple x86_64-pc-linux -S -fseparate-named-sections -o - < %s | FileCheck %s --check-prefix=SEPARATE | ||
|
||
__attribute__((section("custom_text"))) void f(void) {} | ||
__attribute__((section("custom_text"))) void g(void) {} | ||
|
||
// CHECK: .section custom_text,"ax",@progbits{{$}} | ||
// CHECK: f: | ||
// CHECK: g: | ||
|
||
// SEPARATE: .section custom_text,"ax",@progbits,unique,1{{$}} | ||
// SEPARATE: f: | ||
// SEPARATE: .section custom_text,"ax",@progbits,unique,2{{$}} | ||
// SEPARATE: g: | ||
|
||
__attribute__((section("custom_data"))) int i = 0; | ||
__attribute__((section("custom_data"))) int j = 0; | ||
|
||
// CHECK: .section custom_data,"aw",@progbits{{$}} | ||
// CHECK: i: | ||
// CHECK: j: | ||
|
||
// SEPARATE: .section custom_data,"aw",@progbits,unique,3{{$}} | ||
// SEPARATE: i: | ||
// SEPARATE: .section custom_data,"aw",@progbits,unique,4{{$}} | ||
// SEPARATE: j: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
; Test that global values with explicit sections are placed into unique sections. | ||
|
||
; RUN: llc < %s | FileCheck %s | ||
; RUN: llc -separate-named-sections < %s | FileCheck %s --check-prefix=SEPARATE | ||
target triple="x86_64-unknown-unknown-elf" | ||
|
||
define i32 @f() section "custom_text" { | ||
entry: | ||
ret i32 0 | ||
} | ||
|
||
define i32 @g() section "custom_text" { | ||
entry: | ||
ret i32 0 | ||
} | ||
|
||
; CHECK: .section custom_text,"ax",@progbits{{$}} | ||
; CHECK: f: | ||
; CHECK: g: | ||
|
||
; SEPARATE: .section custom_text,"ax",@progbits,unique,1{{$}} | ||
; SEPARATE: f: | ||
; SEPARATE: .section custom_text,"ax",@progbits,unique,2{{$}} | ||
; SEPARATE: g: | ||
|
||
@i = global i32 0, section "custom_data", align 8 | ||
@j = global i32 0, section "custom_data", align 8 | ||
|
||
; CHECK: .section custom_data,"aw",@progbits{{$}} | ||
; CHECK: i: | ||
; CHECK: j: | ||
|
||
; SEPARATE: .section custom_data,"aw",@progbits,unique,3{{$}} | ||
; SEPARATE: i: | ||
; SEPARATE: .section custom_data,"aw",@progbits,unique,4{{$}} | ||
; SEPARATE: j: |