1 // RUN: %clang_cc1 -emit-llvm -triple i686-pc-win32 -fms-extensions -o - %s | FileCheck %s
5 #pragma const_seg(".my_const")
6 #pragma bss_seg(".my_bss")
8 #pragma data_seg(".data")
10 #pragma data_seg(push, label, ".data2")
13 const char* s
= "my string!";
14 #pragma data_seg(push, ".my_seg")
16 #pragma data_seg(pop, label)
22 #pragma code_seg(".my_code")
26 #pragma bss_seg(".bss1")
27 #pragma bss_seg(push, test, ".bss2")
35 // Check "save-restore" of pragma stacks.
38 #pragma bss_seg(push, ".bss3")
39 #pragma code_seg(push, ".my_code1")
40 #pragma const_seg(push, ".my_const1")
41 #pragma data_seg(push, ".data3")
44 #pragma bss_seg(push, ".bss4")
45 #pragma code_seg(push, ".my_code2")
46 #pragma const_seg(push, ".my_const2")
47 #pragma data_seg(push, ".data4")
53 void h2(void) {} // should be in ".my_code"
54 int TEST3
; // should be in ".bss1"
55 int d2
= 1; // should be in ".data"
56 extern const int b2
; // should be in ".my_const"
59 #pragma section("read_flag_section", read)
60 // Even though they are not declared const, these become constant since they are
61 // in a read-only section.
62 __declspec(allocate("read_flag_section")) int unreferenced
= 0;
63 extern __declspec(allocate("read_flag_section")) int referenced
= 42;
64 int *user() { return &referenced
; }
66 #pragma section("no_section_attributes")
67 // A pragma section with no section attributes is read/write.
68 __declspec(allocate("no_section_attributes")) int implicitly_read_write
= 42;
70 #pragma section("long_section", long)
71 // Pragma section ignores "long".
72 __declspec(allocate("long_section")) long long_var
= 42;
74 #pragma section("short_section", short)
75 // Pragma section ignores "short".
76 __declspec(allocate("short_section")) short short_var
= 42;
79 //CHECK: @D = dso_local global i32 1
80 //CHECK: @a = dso_local global i32 1, section ".data"
81 //CHECK: @b = dso_local constant i32 1, section ".my_const"
82 //CHECK: @[[MYSTR:.*]] = {{.*}} unnamed_addr constant [11 x i8] c"my string!\00"
83 //CHECK: @s = dso_local global i8* getelementptr inbounds ([11 x i8], [11 x i8]* @[[MYSTR]], i32 0, i32 0), section ".data2"
84 //CHECK: @c = dso_local global i32 1, section ".my_seg"
85 //CHECK: @d = dso_local global i32 1, section ".data"
86 //CHECK: @e = dso_local global i32 0, section ".my_bss"
87 //CHECK: @f = dso_local global i32 0, section ".c"
88 //CHECK: @i = dso_local global i32 0
89 //CHECK: @TEST1 = dso_local global i32 0
90 //CHECK: @TEST2 = dso_local global i32 0, section ".bss1"
91 //CHECK: @TEST3 = dso_local global i32 0, section ".bss1"
92 //CHECK: @d2 = dso_local global i32 1, section ".data"
93 //CHECK: @b2 = dso_local constant i32 1, section ".my_const"
94 //CHECK: @unreferenced = dso_local constant i32 0, section "read_flag_section"
95 //CHECK: @referenced = dso_local constant i32 42, section "read_flag_section"
96 //CHECK: @implicitly_read_write = dso_local global i32 42, section "no_section_attributes"
97 //CHECK: @long_var = dso_local global i32 42, section "long_section"
98 //CHECK: @short_var = dso_local global i16 42, section "short_section"
99 //CHECK: define dso_local void @g()
100 //CHECK: define dso_local void @h() {{.*}} section ".my_code"
101 //CHECK: define dso_local void @h2() {{.*}} section ".my_code"