[docs] Add LICENSE.txt to the root of the mono-repo
[llvm-project.git] / clang / test / Driver / arm-float-abi-lto.c
blob8b6d8ff6b5d7a1f0c5bacdaaa5635572402c834d
1 // REQUIRES: arm-registered-target
3 // RUN: %clang --target=arm-none-eabi -mcpu=cortex-m33 -mfloat-abi=hard -O1 %s -S -o - -emit-llvm -DCALL_LIB -DDEFINE_LIB | FileCheck %s
5 // RUN: %clang --target=arm-none-eabi -mcpu=cortex-m33 -mfloat-abi=hard -O1 %s -Xclang -opaque-pointers -flto=full -c -o %t.call_full.bc -DCALL_LIB
6 // RUN: %clang --target=arm-none-eabi -mcpu=cortex-m33 -mfloat-abi=hard -O1 %s -Xclang -opaque-pointers -flto=full -c -o %t.define_full.bc -DDEFINE_LIB
7 // RUN: llvm-lto2 run -lto-opaque-pointers -o %t.lto_full -save-temps %t.call_full.bc %t.define_full.bc \
8 // RUN: -r %t.call_full.bc,fn,px \
9 // RUN: -r %t.call_full.bc,fwrite,l \
10 // RUN: -r %t.call_full.bc,putchar,l \
11 // RUN: -r %t.call_full.bc,stdout,px \
12 // RUN: -r %t.define_full.bc,fwrite,px \
13 // RUN: -r %t.define_full.bc,putchar,px \
14 // RUN: -r %t.define_full.bc,otherfn,px
15 // RUN: llvm-dis %t.lto_full.0.4.opt.bc -o - | FileCheck %s
17 // RUN: %clang --target=arm-none-eabi -mcpu=cortex-m33 -mfloat-abi=hard -O1 %s -Xclang -opaque-pointers -flto=thin -c -o %t.call_thin.bc -DCALL_LIB
18 // RUN: %clang --target=arm-none-eabi -mcpu=cortex-m33 -mfloat-abi=hard -O1 %s -Xclang -opaque-pointers -flto=thin -c -o %t.define_thin.bc -DDEFINE_LIB
19 // RUN: llvm-lto2 run -lto-opaque-pointers -o %t.lto_thin -save-temps %t.call_thin.bc %t.define_thin.bc \
20 // RUN: -r %t.call_thin.bc,fn,px \
21 // RUN: -r %t.call_thin.bc,fwrite,l \
22 // RUN: -r %t.call_thin.bc,putchar,l \
23 // RUN: -r %t.call_thin.bc,stdout,px \
24 // RUN: -r %t.define_thin.bc,fwrite,px \
25 // RUN: -r %t.define_thin.bc,putchar,px \
26 // RUN: -r %t.define_thin.bc,otherfn,px
27 // RUN: llvm-dis %t.lto_thin.1.4.opt.bc -o - | FileCheck %s
29 // We expect that the fprintf is optimised to fwrite, and the printf is
30 // optimised to putchar. Check that we don't have a mismatch in calling
31 // conventions causing the call to be replaced by a trap.
32 // CHECK-LABEL: define{{.*}}void @fn()
33 // CHECK-NOT: call void @llvm.trap()
35 typedef struct FILE FILE;
36 typedef unsigned int size_t;
37 extern FILE *stdout;
38 extern int fprintf(FILE *, const char *, ...);
39 extern int printf(const char *, ...);
40 extern void otherfn(const void *);
42 #ifdef CALL_LIB
44 void fn() {
45 fprintf(stdout, "hello world");
46 printf("a");
49 #endif
51 #ifdef DEFINE_LIB
53 size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) {
54 otherfn(ptr);
55 return 0;
58 int putchar(int c) {
59 otherfn(&c);
60 return 0;
63 #endif