Joseph Huber 41fba3c107 [Metadata] Add 'exclude' metadata to add the exclude flags on globals
This patchs adds a new metadata kind `exclude` which implies that the
global variable should be given the necessary flags during code
generation to not be included in the final executable. This is done
using the ``SHF_EXCLUDE`` flag on ELF for example. This should make it
easier to specify this flag on a variable without needing to explicitly
check the section name in the target backend.

Depends on D129053 D129052

Reviewed By: jdoerfert

Differential Revision: https://reviews.llvm.org/D129151
2022-07-07 12:20:40 -04:00

19 lines
563 B
LLVM

; RUN: llc -mtriple x86_64-pc-linux-gnu < %s | FileCheck %s
@a = global i32 1
@b = global i32 1, !exclude !0
@c = global i32 1, section "aaa"
; CHECK-DAG: .type c,@object
; CHECK-DAG: .section aaa,"aw",@progbits
@d = global i32 1, section "bbb", !exclude !0
; CHECK-DAG: .type d,@object
; CHECK-DAG: .section bbb,"e",@progbits
@e = global i32 1, section "bbb", !exclude !0
; CHECK-DAG: .type e,@object
@f = global i32 1, section "ccc", !exclude !0
@g = global i32 1, section "ccc"
; CHECK-DAG: .type f,@object
; CHECK-DAG: .section ccc,"e",@progbits
!0 = !{}