File: arm-float-abi-lto.c

package info (click to toggle)
swiftlang 6.1.3-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,791,604 kB
  • sloc: cpp: 9,901,740; ansic: 2,201,431; asm: 1,091,827; python: 308,252; objc: 82,166; f90: 80,126; lisp: 38,358; pascal: 25,559; sh: 20,429; ml: 5,058; perl: 4,745; makefile: 4,484; awk: 3,535; javascript: 3,018; xml: 918; fortran: 664; cs: 573; ruby: 396
file content (63 lines) | stat: -rw-r--r-- 2,275 bytes parent folder | download | duplicates (19)
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