brintos

brintos / llvm-project-archived public Read only

0
0
Text · 4.0 KiB · 5afef72 Raw
126 lines · c
1// RUN: %clang_cc1 -emit-llvm -Wno-strict-prototypes -Wno-incompatible-function-pointer-types -fcf-protection=branch -triple i386-linux-gnu %s -o - | FileCheck %s2 3// CHECK: @t5 = weak{{.*}} global i32 24int t5 __attribute__((weak)) = 2;5 6// CHECK: @t13 ={{.*}} global %struct.s0 zeroinitializer, section "SECT"7struct s0 { int x; };8struct s0 t13 __attribute__((section("SECT"))) = { 0 };9 10// CHECK: @t14.x = internal global i32 0, section "SECT"11void t14(void) {12  static int x __attribute__((section("SECT"))) = 0;13}14 15// CHECK: @t18 ={{.*}} global i32 1, align 416extern int t18 __attribute__((weak_import));17int t18 = 1;18 19// CHECK: @t16 = extern_weak global i3220extern int t16 __attribute__((weak_import));21 22// CHECK: @t6 = protected global i32 023int t6 __attribute__((visibility("protected")));24 25// CHECK: @t12 ={{.*}} global i32 0, section "SECT"26int t12 __attribute__((section("SECT")));27 28// CHECK: @t9 = weak{{.*}} alias void (...), ptr @__t829void __t8() {}30void t9() __attribute__((weak, alias("__t8")));31 32// CHECK: declare extern_weak i32 @t15()33int __attribute__((weak_import)) t15(void);34int t17(void) {35  return t15() + t16;36}37 38// CHECK: define{{.*}} void @t1() [[NR:#[0-9]+]] {39void t1(void) __attribute__((noreturn));40void t1(void) { while (1) {} }41 42// CHECK: define{{.*}} void @t2() [[NUW:#[0-9]+]] {43void t2(void) __attribute__((nothrow));44void t2(void) {}45 46// CHECK: define weak{{.*}} void @t3() [[NUW]] {47void t3(void) __attribute__((weak));48void t3(void) {}49 50// CHECK: define hidden void @t4() [[NUW]] {51void t4(void) __attribute__((visibility("hidden")));52void t4(void) {}53 54// CHECK: define{{.*}} void @t7() [[NR]] {55void t7(void) __attribute__((noreturn, nothrow));56void t7(void) { while (1) {} }57 58// CHECK: define{{.*}} void @t72() [[COLDDEF:#[0-9]+]] {59void t71(void) __attribute__((cold));60void t72(void) __attribute__((cold));61void t72(void) { t71(); }62// CHECK: call void @t71() [[COLDSITE:#[0-9]+]]63// CHECK: declare void @t71() [[COLDDECL:#[0-9]+]]64 65// CHECK: define{{.*}} void @t82() [[HOTDEF:#[0-9]+]] {66void t81(void) __attribute__((hot));67void t82(void) __attribute__((hot));68void t82(void) { t81(); }69// CHECK: call void @t81() [[HOTSITE:#[0-9]+]]70// CHECK: declare void @t81() [[HOTDECL:#[0-9]+]]71 72// CHECK: define{{.*}} void @t10() [[NUW]] section "xSECT" {73void t10(void) __attribute__((section("xSECT")));74void t10(void) {}75// CHECK: define{{.*}} void @t11() [[NUW]] section "xSECT" {76void __attribute__((section("xSECT"))) t11(void) {}77 78// CHECK: define{{.*}} i32 @t19() [[NUW]] {79extern int t19(void) __attribute__((weak_import));80int t19(void) {81  return 10;82}83 84// CHECK:define{{.*}} void @t20() [[NUW]] {85// CHECK: call void @abort()86// CHECK-NEXT: unreachable87void t20(void) {88  __builtin_abort();89}90 91void (__attribute__((fastcall)) *fptr)(int);92void t21(void) {93  fptr(10);94}95// CHECK: [[FPTRVAR:%[a-z0-9]+]] = load ptr, ptr @fptr96// CHECK-NEXT: call x86_fastcallcc void [[FPTRVAR]](i32 inreg noundef 10)97 98 99// PR9356: We might want to err on this, but for now at least make sure we100// use the section in the definition.101void __attribute__((section(".foo"))) t22(void);102void __attribute__((section(".bar"))) t22(void) {}103 104// CHECK: define{{.*}} void @t22() [[NUW]] section ".bar"105 106// CHECK: define{{.*}} void @t23() [[NOCF_CHECK_FUNC:#[0-9]+]]107void __attribute__((nocf_check)) t23(void) {}108 109// CHECK: call void %{{[a-z0-9]+}}() [[NOCF_CHECK_CALL:#[0-9]+]]110typedef void (*f_t)(void);111void t24(f_t f1) {112  __attribute__((nocf_check)) f_t p = f1;113  (*p)();114}115 116// CHECK: attributes [[NUW]] = { noinline nounwind{{.*}} }117// CHECK: attributes [[NR]] = { noinline noreturn nounwind{{.*}} }118// CHECK: attributes [[COLDDEF]] = { cold {{.*}}}119// CHECK: attributes [[COLDDECL]] = { cold {{.*}}}120// CHECK: attributes [[HOTDEF]] = { hot {{.*}}}121// CHECK: attributes [[HOTDECL]] = { hot {{.*}}}122// CHECK: attributes [[NOCF_CHECK_FUNC]] = { nocf_check {{.*}}}123// CHECK: attributes [[COLDSITE]] = { cold {{.*}}}124// CHECK: attributes [[HOTSITE]] = { hot {{.*}}}125// CHECK: attributes [[NOCF_CHECK_CALL]] = { nocf_check }126