brintos

brintos / llvm-project-archived public Read only

0
0
Text · 2.2 KiB · 83c2435 Raw
64 lines · c
1// REQUIRES: arm-registered-target2 3// RUN: %clang --target=arm-none-eabi -mcpu=cortex-m33 -mfloat-abi=hard -O1 %s -S -o - -emit-llvm -DCALL_LIB -DDEFINE_LIB | FileCheck %s4 5// RUN: %clang --target=arm-none-eabi -mcpu=cortex-m33 -mfloat-abi=hard -O1 %s -flto=full -c -o %t.call_full.bc -DCALL_LIB6// RUN: %clang --target=arm-none-eabi -mcpu=cortex-m33 -mfloat-abi=hard -O1 %s -flto=full -c -o %t.define_full.bc -DDEFINE_LIB7// RUN: llvm-lto2 run -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,px15// RUN: llvm-dis %t.lto_full.0.4.opt.bc -o - | FileCheck %s16 17// RUN: %clang --target=arm-none-eabi -mcpu=cortex-m33 -mfloat-abi=hard -O1 %s -flto=thin -c -o %t.call_thin.bc -DCALL_LIB18// RUN: %clang --target=arm-none-eabi -mcpu=cortex-m33 -mfloat-abi=hard -O1 %s -flto=thin -c -o %t.define_thin.bc -DDEFINE_LIB19// RUN: llvm-lto2 run -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,px27// RUN: llvm-dis %t.lto_thin.1.4.opt.bc -o - | FileCheck %s28 29// We expect that the fprintf is optimised to fwrite, and the printf is30// optimised to putchar. Check that we don't have a mismatch in calling31// conventions causing the call to be replaced by a trap.32// CHECK-LABEL: define{{.*}}void @fn()33// CHECK-NOT: call void @llvm.trap()34 35typedef struct FILE FILE;36typedef unsigned int size_t;37extern FILE *stdout;38extern int fprintf(FILE *, const char *, ...);39extern int printf(const char *, ...);40extern void otherfn(const void *);41 42#ifdef CALL_LIB43 44void fn() {45  fprintf(stdout, "hello world");46  printf("a");47}48 49#endif50 51#ifdef DEFINE_LIB52 53size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) {54  otherfn(ptr);55  return 0;56}57 58int putchar(int c) {59  otherfn(&c);60  return 0;61}62 63#endif64