Revert "[llvm] Improve llvm.objectsize computation by computing GEP, alloca and mallo...
[llvm-project.git] / clang / test / CodeGen / asm-label.c
blobc901223db990d0ecc9b551adac9a13e2265fedf6
1 // RUN: %clang_cc1 -triple=i686-pc-linux-gnu -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,LINUX
2 // RUN: %clang_cc1 -triple=i686-apple-darwin9 -emit-llvm %s -o - | FileCheck %s --check-prefixes=CHECK,DARWIN
4 char *strerror(int) asm("alias");
5 int x __asm("foo");
7 int *test(void) {
8 static int y __asm("bar");
9 strerror(-1);
10 return &y;
13 // LINUX: @bar = internal global i32 0
14 // LINUX: @foo ={{.*}} global i32 0
15 // LINUX: declare ptr @alias(i32 noundef)
17 // DARWIN: @"\01bar" = internal global i32 0
18 // DARWIN: @"\01foo" ={{.*}} global i32 0
19 // DARWIN: declare ptr @"\01alias"(i32 noundef)
21 extern void *memcpy(void *__restrict, const void *__restrict, unsigned long);
22 extern __typeof(memcpy) memcpy asm("__GI_memcpy");
23 void test_memcpy(void *dst, void *src, unsigned long n) {
24 memcpy(dst, src, n);
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)
32 long lrint(double x) asm("__GI_lrint");
33 long test_lrint(double x) {
34 return lrint(x);
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)
42 /// NOTE: GCC can optimize out abs in -O1 or above. Clang does not
43 /// communicate the mapping to the backend so the libcall cannot be eliminated.
44 int abs(int x) asm("__GI_abs");
45 long test_abs(int x) {
46 return abs(x);
48 // CHECK-LABEL: @test_abs(
49 // LINUX: call i32 @__GI_abs(
51 /// FIXME: test_sin should call real_sin instead.
52 double sin(double x) asm("real_sin");
53 double test_sin(double d) { return __builtin_sin(d); }
54 // CHECK-LABEL: @test_sin(
55 // LINUX: call double @llvm.sin.f64(