2009-12-16 04:14:24 +08:00
|
|
|
// RUN: %clang_cc1 -emit-llvm -triple i386-linux-gnu -o %t %s
|
2009-10-07 06:58:45 +08:00
|
|
|
// RUN: FileCheck --input-file=%t %s
|
2008-09-27 08:39:13 +08:00
|
|
|
|
2009-10-07 06:58:45 +08:00
|
|
|
// CHECK: @t5 = weak global i32 2
|
|
|
|
int t5 __attribute__((weak)) = 2;
|
|
|
|
|
2011-06-20 12:01:35 +08:00
|
|
|
// CHECK: @t13 = global %struct.s0 zeroinitializer, section "SECT"
|
2009-10-07 06:58:45 +08:00
|
|
|
struct s0 { int x; };
|
|
|
|
struct s0 t13 __attribute__((section("SECT"))) = { 0 };
|
|
|
|
|
|
|
|
// CHECK: @t14.x = internal global i32 0, section "SECT"
|
|
|
|
void t14(void) {
|
|
|
|
static int x __attribute__((section("SECT"))) = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// CHECK: @t18 = global i32 1, align 4
|
|
|
|
extern int t18 __attribute__((weak_import));
|
|
|
|
int t18 = 1;
|
|
|
|
|
|
|
|
// CHECK: @t16 = extern_weak global i32
|
|
|
|
extern int t16 __attribute__((weak_import));
|
|
|
|
|
|
|
|
// CHECK: @t6 = common protected global i32 0
|
|
|
|
int t6 __attribute__((visibility("protected")));
|
|
|
|
|
|
|
|
// CHECK: @t12 = global i32 0, section "SECT"
|
|
|
|
int t12 __attribute__((section("SECT")));
|
|
|
|
|
|
|
|
// CHECK: @t9 = alias weak bitcast (void ()* @__t8 to void (...)*)
|
|
|
|
void __t8() {}
|
|
|
|
void t9() __attribute__((weak, alias("__t8")));
|
|
|
|
|
|
|
|
// CHECK: declare extern_weak i32 @t15()
|
|
|
|
int __attribute__((weak_import)) t15(void);
|
|
|
|
int t17() {
|
|
|
|
return t15() + t16;
|
|
|
|
}
|
|
|
|
|
2013-02-16 05:30:01 +08:00
|
|
|
// CHECK: define void @t1() noreturn nounwind {{.*}} {
|
2008-03-03 11:28:21 +08:00
|
|
|
void t1() __attribute__((noreturn));
|
2009-07-24 10:49:01 +08:00
|
|
|
void t1() { while (1) {} }
|
2008-03-03 11:28:21 +08:00
|
|
|
|
2013-02-16 05:30:01 +08:00
|
|
|
// CHECK: define void @t2() nounwind {{.*}} {
|
2008-03-03 11:28:21 +08:00
|
|
|
void t2() __attribute__((nothrow));
|
|
|
|
void t2() {}
|
|
|
|
|
2013-02-16 05:30:01 +08:00
|
|
|
// CHECK: define weak void @t3() nounwind {{.*}} {
|
2008-03-03 11:28:21 +08:00
|
|
|
void t3() __attribute__((weak));
|
|
|
|
void t3() {}
|
|
|
|
|
2013-02-16 05:30:01 +08:00
|
|
|
// CHECK: define hidden void @t4() nounwind {{.*}} {
|
2008-03-05 02:08:48 +08:00
|
|
|
void t4() __attribute__((visibility("hidden")));
|
2008-03-03 11:28:21 +08:00
|
|
|
void t4() {}
|
|
|
|
|
2013-02-16 05:30:01 +08:00
|
|
|
// CHECK: define void @t7() noreturn nounwind {{.*}} {
|
2008-03-03 11:45:26 +08:00
|
|
|
void t7() __attribute__((noreturn, nothrow));
|
2009-07-24 10:49:01 +08:00
|
|
|
void t7() { while (1) {} }
|
2008-06-08 23:45:52 +08:00
|
|
|
|
2013-02-16 05:30:01 +08:00
|
|
|
// CHECK: define void @t10() nounwind {{.*}} section "SECT" {
|
2009-02-13 01:28:23 +08:00
|
|
|
void t10(void) __attribute__((section("SECT")));
|
|
|
|
void t10(void) {}
|
2013-02-16 05:30:01 +08:00
|
|
|
// CHECK: define void @t11() nounwind {{.*}} section "SECT" {
|
2009-02-13 01:28:23 +08:00
|
|
|
void __attribute__((section("SECT"))) t11(void) {}
|
|
|
|
|
2013-02-16 05:30:01 +08:00
|
|
|
// CHECK: define i32 @t19() nounwind {{.*}} {
|
2009-06-06 06:58:34 +08:00
|
|
|
extern int t19(void) __attribute__((weak_import));
|
|
|
|
int t19(void) {
|
|
|
|
return 10;
|
|
|
|
}
|
|
|
|
|
2013-02-16 05:30:01 +08:00
|
|
|
// CHECK:define void @t20() nounwind {{.*}} {
|
2009-11-11 11:48:34 +08:00
|
|
|
// CHECK: call void @abort()
|
2009-10-07 06:58:45 +08:00
|
|
|
// CHECK-NEXT: unreachable
|
|
|
|
void t20(void) {
|
|
|
|
__builtin_abort();
|
|
|
|
}
|
2010-02-06 05:31:56 +08:00
|
|
|
|
|
|
|
void (__attribute__((fastcall)) *fptr)(int);
|
|
|
|
void t21(void) {
|
|
|
|
fptr(10);
|
|
|
|
}
|
|
|
|
// CHECK: [[FPTRVAR:%[a-z0-9]+]] = load void (i32)** @fptr
|
2012-10-24 09:58:58 +08:00
|
|
|
// CHECK-NEXT: call x86_fastcallcc void [[FPTRVAR]](i32 inreg 10)
|
2012-05-13 09:56:10 +08:00
|
|
|
|
|
|
|
|
|
|
|
// PR9356: We might want to err on this, but for now at least make sure we
|
|
|
|
// use the section in the definition.
|
|
|
|
void __attribute__((section(".foo"))) t22(void);
|
|
|
|
void __attribute__((section(".bar"))) t22(void) {}
|
|
|
|
|
2013-02-16 05:30:01 +08:00
|
|
|
// CHECK: define void @t22() nounwind {{.*}} section ".bar"
|