1f4a2713aSLionel Sambuc // RUN: %clang_cc1 -emit-llvm -triple i386-linux-gnu -o %t %s 2f4a2713aSLionel Sambuc // RUN: FileCheck --input-file=%t %s 3f4a2713aSLionel Sambuc 4f4a2713aSLionel Sambuc // CHECK: @t5 = weak global i32 2 5f4a2713aSLionel Sambuc int t5 __attribute__((weak)) = 2; 6f4a2713aSLionel Sambuc 7f4a2713aSLionel Sambuc // CHECK: @t13 = global %struct.s0 zeroinitializer, section "SECT" 8f4a2713aSLionel Sambuc struct s0 { int x; }; 9f4a2713aSLionel Sambuc struct s0 t13 __attribute__((section("SECT"))) = { 0 }; 10f4a2713aSLionel Sambuc 11f4a2713aSLionel Sambuc // CHECK: @t14.x = internal global i32 0, section "SECT" t14(void)12f4a2713aSLionel Sambucvoid t14(void) { 13f4a2713aSLionel Sambuc static int x __attribute__((section("SECT"))) = 0; 14f4a2713aSLionel Sambuc } 15f4a2713aSLionel Sambuc 16f4a2713aSLionel Sambuc // CHECK: @t18 = global i32 1, align 4 17f4a2713aSLionel Sambuc extern int t18 __attribute__((weak_import)); 18f4a2713aSLionel Sambuc int t18 = 1; 19f4a2713aSLionel Sambuc 20f4a2713aSLionel Sambuc // CHECK: @t16 = extern_weak global i32 21f4a2713aSLionel Sambuc extern int t16 __attribute__((weak_import)); 22f4a2713aSLionel Sambuc 23f4a2713aSLionel Sambuc // CHECK: @t6 = common protected global i32 0 24f4a2713aSLionel Sambuc int t6 __attribute__((visibility("protected"))); 25f4a2713aSLionel Sambuc 26f4a2713aSLionel Sambuc // CHECK: @t12 = global i32 0, section "SECT" 27f4a2713aSLionel Sambuc int t12 __attribute__((section("SECT"))); 28f4a2713aSLionel Sambuc 29*0a6a1f1dSLionel Sambuc // CHECK: @t9 = weak alias bitcast (void ()* @__t8 to void (...)*) __t8()30f4a2713aSLionel Sambucvoid __t8() {} 31f4a2713aSLionel Sambuc void t9() __attribute__((weak, alias("__t8"))); 32f4a2713aSLionel Sambuc 33f4a2713aSLionel Sambuc // CHECK: declare extern_weak i32 @t15() 34f4a2713aSLionel Sambuc int __attribute__((weak_import)) t15(void); t17()35f4a2713aSLionel Sambucint t17() { 36f4a2713aSLionel Sambuc return t15() + t16; 37f4a2713aSLionel Sambuc } 38f4a2713aSLionel Sambuc 39f4a2713aSLionel Sambuc // CHECK: define void @t1() [[NR:#[0-9]+]] { 40f4a2713aSLionel Sambuc void t1() __attribute__((noreturn)); t1()41f4a2713aSLionel Sambucvoid t1() { while (1) {} } 42f4a2713aSLionel Sambuc 43f4a2713aSLionel Sambuc // CHECK: define void @t2() [[NUW:#[0-9]+]] { 44f4a2713aSLionel Sambuc void t2() __attribute__((nothrow)); t2()45f4a2713aSLionel Sambucvoid t2() {} 46f4a2713aSLionel Sambuc 47f4a2713aSLionel Sambuc // CHECK: define weak void @t3() [[NUW]] { 48f4a2713aSLionel Sambuc void t3() __attribute__((weak)); t3()49f4a2713aSLionel Sambucvoid t3() {} 50f4a2713aSLionel Sambuc 51f4a2713aSLionel Sambuc // CHECK: define hidden void @t4() [[NUW]] { 52f4a2713aSLionel Sambuc void t4() __attribute__((visibility("hidden"))); t4()53f4a2713aSLionel Sambucvoid t4() {} 54f4a2713aSLionel Sambuc 55f4a2713aSLionel Sambuc // CHECK: define void @t7() [[NR]] { 56f4a2713aSLionel Sambuc void t7() __attribute__((noreturn, nothrow)); t7()57f4a2713aSLionel Sambucvoid t7() { while (1) {} } 58f4a2713aSLionel Sambuc 59f4a2713aSLionel Sambuc // CHECK: define void @t10() [[NUW]] section "SECT" { 60f4a2713aSLionel Sambuc void t10(void) __attribute__((section("SECT"))); t10(void)61f4a2713aSLionel Sambucvoid t10(void) {} 62f4a2713aSLionel Sambuc // CHECK: define void @t11() [[NUW]] section "SECT" { t11(void)63f4a2713aSLionel Sambucvoid __attribute__((section("SECT"))) t11(void) {} 64f4a2713aSLionel Sambuc 65f4a2713aSLionel Sambuc // CHECK: define i32 @t19() [[NUW]] { 66f4a2713aSLionel Sambuc extern int t19(void) __attribute__((weak_import)); t19(void)67f4a2713aSLionel Sambucint t19(void) { 68f4a2713aSLionel Sambuc return 10; 69f4a2713aSLionel Sambuc } 70f4a2713aSLionel Sambuc 71f4a2713aSLionel Sambuc // CHECK:define void @t20() [[NUW]] { 72f4a2713aSLionel Sambuc // CHECK: call void @abort() 73f4a2713aSLionel Sambuc // CHECK-NEXT: unreachable t20(void)74f4a2713aSLionel Sambucvoid t20(void) { 75f4a2713aSLionel Sambuc __builtin_abort(); 76f4a2713aSLionel Sambuc } 77f4a2713aSLionel Sambuc 78f4a2713aSLionel Sambuc void (__attribute__((fastcall)) *fptr)(int); t21(void)79f4a2713aSLionel Sambucvoid t21(void) { 80f4a2713aSLionel Sambuc fptr(10); 81f4a2713aSLionel Sambuc } 82f4a2713aSLionel Sambuc // CHECK: [[FPTRVAR:%[a-z0-9]+]] = load void (i32)** @fptr 83f4a2713aSLionel Sambuc // CHECK-NEXT: call x86_fastcallcc void [[FPTRVAR]](i32 inreg 10) 84f4a2713aSLionel Sambuc 85f4a2713aSLionel Sambuc 86f4a2713aSLionel Sambuc // PR9356: We might want to err on this, but for now at least make sure we 87f4a2713aSLionel Sambuc // use the section in the definition. 88f4a2713aSLionel Sambuc void __attribute__((section(".foo"))) t22(void); t22(void)89f4a2713aSLionel Sambucvoid __attribute__((section(".bar"))) t22(void) {} 90f4a2713aSLionel Sambuc 91f4a2713aSLionel Sambuc // CHECK: define void @t22() [[NUW]] section ".bar" 92f4a2713aSLionel Sambuc 93f4a2713aSLionel Sambuc // CHECK: attributes [[NUW]] = { nounwind{{.*}} } 94f4a2713aSLionel Sambuc // CHECK: attributes [[NR]] = { noreturn nounwind{{.*}} } 95