56 lines · c
1// RUN: %clang_cc1 -triple=i686-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,LINUX2// RUN: %clang_cc1 -triple=i686-apple-darwin9 -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,DARWIN3 4char *strerror(int) asm("alias");5int x __asm("foo");6 7int *test(void) {8 static int y __asm("bar");9 strerror(-1);10 return &y;11}12 13// LINUX: @bar = internal global i32 014// LINUX: @foo ={{.*}} global i32 015// LINUX: declare ptr @alias(i32 noundef)16 17// DARWIN: @"\01bar" = internal global i32 018// DARWIN: @"\01foo" ={{.*}} global i32 019// DARWIN: declare ptr @"\01alias"(i32 noundef)20 21extern void *memcpy(void *__restrict, const void *__restrict, unsigned long);22extern __typeof(memcpy) memcpy asm("__GI_memcpy");23void test_memcpy(void *dst, void *src, unsigned long n) {24 memcpy(dst, src, n);25}26// CHECK-LABEL: @test_memcpy(27// LINUX: call ptr @__GI_memcpy(28// LINUX: declare ptr @__GI_memcpy(ptr noundef, ptr noundef, i32 noundef)29// DARWIN: call ptr @"\01__GI_memcpy"(30// DARWIN: declare ptr @"\01__GI_memcpy"(ptr noundef, ptr noundef, i32 noundef)31 32long lrint(double x) asm("__GI_lrint");33long test_lrint(double x) {34 return lrint(x);35}36// CHECK-LABEL: @test_lrint(37// LINUX: call i32 @__GI_lrint(38// LINUX: declare i32 @__GI_lrint(double noundef)39// DARWIN: call i32 @"\01__GI_lrint"(40// DARWIN: declare i32 @"\01__GI_lrint"(double noundef)41 42/// NOTE: GCC can optimize out abs in -O1 or above. Clang does not43/// communicate the mapping to the backend so the libcall cannot be eliminated.44int abs(int x) asm("__GI_abs");45long test_abs(int x) {46 return abs(x);47}48// CHECK-LABEL: @test_abs(49// LINUX: call i32 @__GI_abs(50 51/// FIXME: test_sin should call real_sin instead.52double sin(double x) asm("real_sin");53double test_sin(double d) { return __builtin_sin(d); }54// CHECK-LABEL: @test_sin(55// LINUX: call double @llvm.sin.f64(56