brintos

brintos / llvm-project-archived public Read only

0
0
Text · 1.2 KiB · fc41be7 Raw
30 lines · c
1// RUN: %clang_cc1 -emit-llvm -triple x86_64 %s -o - | FileCheck %s2 3/// Set !retain regardless of the target. The backend will lower !retain to4/// SHF_GNU_RETAIN on ELF and ignore the metadata for other binary formats.5// CHECK:      @c0 ={{.*}} constant i32 {{.*}}6// CHECK:      @foo.l0 = internal global i32 {{.*}}7// CHECK:      @g0 ={{.*}} global i32 {{.*}}8// CHECK-NEXT: @g1 ={{.*}} global i32 {{.*}}9// CHECK-NEXT: @g3 = internal global i32 {{.*}}10// CHECK-NEXT: @g4 = internal global i32 0, section ".data.g"{{.*}}11 12// CHECK:      @llvm.used = appending global [8 x ptr] [ptr @c0, ptr @foo.l0, ptr @f0, ptr @f2, ptr @g0, ptr @g1, ptr @g3, ptr @g4], section "llvm.metadata"13// CHECK:      @llvm.compiler.used = appending global [3 x ptr] [ptr @f2, ptr @g3, ptr @g4], section "llvm.metadata"14 15const int c0 __attribute__((retain)) = 42;16 17void foo(void) {18  static int l0 __attribute__((retain)) = 2;19}20 21__attribute__((retain)) int g0;22int g1 __attribute__((retain));23__attribute__((retain)) static int g2;24__attribute__((used, retain)) static int g3;25__attribute__((used, retain, section(".data.g"))) static int g4;26 27void __attribute__((retain)) f0(void) {}28static void __attribute__((retain)) f1(void) {}29static void __attribute__((used, retain)) f2(void) {}30