File: arm-float-abi-lto.c

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-16
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,496,368 kB
  • sloc: cpp: 5,593,980; ansic: 986,873; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,547; xml: 953; cs: 573; fortran: 567
file content (63 lines) | stat: -rw-r--r-- 2,275 bytes parent folder | download | duplicates (16)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
// REQUIRES: arm-registered-target

// RUN: %clang --target=arm-none-eabi -mcpu=cortex-m33 -mfloat-abi=hard -O1 %s -S -o - -emit-llvm -DCALL_LIB -DDEFINE_LIB | FileCheck %s

// RUN: %clang --target=arm-none-eabi -mcpu=cortex-m33 -mfloat-abi=hard -O1 %s -flto=full -c -o %t.call_full.bc -DCALL_LIB
// RUN: %clang --target=arm-none-eabi -mcpu=cortex-m33 -mfloat-abi=hard -O1 %s -flto=full -c -o %t.define_full.bc -DDEFINE_LIB
// RUN: llvm-lto2 run -o %t.lto_full -save-temps %t.call_full.bc %t.define_full.bc \
// RUN:  -r %t.call_full.bc,fn,px \
// RUN:  -r %t.call_full.bc,fwrite,l \
// RUN:  -r %t.call_full.bc,putchar,l \
// RUN:  -r %t.call_full.bc,stdout,px \
// RUN:  -r %t.define_full.bc,fwrite,px \
// RUN:  -r %t.define_full.bc,putchar,px \
// RUN:  -r %t.define_full.bc,otherfn,px
// RUN: llvm-dis %t.lto_full.0.4.opt.bc -o - | FileCheck %s

// RUN: %clang --target=arm-none-eabi -mcpu=cortex-m33 -mfloat-abi=hard -O1 %s -flto=thin -c -o %t.call_thin.bc -DCALL_LIB
// RUN: %clang --target=arm-none-eabi -mcpu=cortex-m33 -mfloat-abi=hard -O1 %s -flto=thin -c -o %t.define_thin.bc -DDEFINE_LIB
// RUN: llvm-lto2 run -o %t.lto_thin -save-temps %t.call_thin.bc %t.define_thin.bc \
// RUN:  -r %t.call_thin.bc,fn,px \
// RUN:  -r %t.call_thin.bc,fwrite,l \
// RUN:  -r %t.call_thin.bc,putchar,l \
// RUN:  -r %t.call_thin.bc,stdout,px \
// RUN:  -r %t.define_thin.bc,fwrite,px \
// RUN:  -r %t.define_thin.bc,putchar,px \
// RUN:  -r %t.define_thin.bc,otherfn,px
// RUN: llvm-dis %t.lto_thin.1.4.opt.bc -o - | FileCheck %s

// We expect that the fprintf is optimised to fwrite, and the printf is
// optimised to putchar. Check that we don't have a mismatch in calling
// conventions causing the call to be replaced by a trap.
// CHECK-LABEL: define{{.*}}void @fn()
// CHECK-NOT: call void @llvm.trap()

typedef struct FILE FILE;
typedef unsigned int size_t;
extern FILE *stdout;
extern int fprintf(FILE *, const char *, ...);
extern int printf(const char *, ...);
extern void otherfn(const void *);

#ifdef CALL_LIB

void fn() {
  fprintf(stdout, "hello world");
  printf("a");
}

#endif

#ifdef DEFINE_LIB

size_t fwrite(const void *ptr, size_t size, size_t nmemb, FILE *stream) {
  otherfn(ptr);
  return 0;
}

int putchar(int c) {
  otherfn(&c);
  return 0;
}

#endif