1 ; Test -lto-freestanding option for libLTO.
2 ; RUN: llvm-as < %s > %t.bc
4 ; Regular run: expects fprintf to be turned into fwrite
5 ; RUN: llvm-lto %t.bc -exported-symbol=_foo -o %t.o
6 ; RUN: llvm-nm %t.o | FileCheck %s --check-prefix=LTO
9 ; Freestanding run: expects fprintf to NOT be turned into fwrite
10 ; RUN: llvm-lto %t.bc -lto-freestanding -exported-symbol=_foo -o %t.o
11 ; RUN: llvm-nm %t.o | FileCheck %s --check-prefix=LTO-FREESTANDING
12 ; LTO-FREESTANDING: fprintf
14 ; Test -lto-freestanding option for LTOBackend & legacy PM.
16 ; RUN: llvm-lto2 run -r %t.bc,_fprintf,px -r %t.bc,_hello_world,px -r %t.bc,_percent_s,px -r %t.bc,_foo,px %t.bc -o %t1.o 2>&1
17 ; RUN: llvm-nm %t1.o.0 | FileCheck %s --check-prefix=LTO
19 ; RUN: llvm-lto2 run -lto-freestanding -r %t.bc,_fprintf,px -r %t.bc,_hello_world,px -r %t.bc,_percent_s,px -r %t.bc,_foo,px %t.bc -o %t2.o 2>&1
20 ; RUN: llvm-nm %t2.o.0 | FileCheck %s --check-prefix=LTO-FREESTANDING
22 ; Test -lto-freestanding option for LTOBackend & new PM.
24 ; RUN: llvm-lto2 run -use-new-pm -r %t.bc,_fprintf,px -r %t.bc,_hello_world,px -r %t.bc,_percent_s,px -r %t.bc,_foo,px %t.bc -o %t1.o 2>&1
25 ; RUN: llvm-nm %t1.o.0 | FileCheck %s --check-prefix=LTO
27 ; RUN: llvm-lto2 run -use-new-pm -lto-freestanding -r %t.bc,_fprintf,px -r %t.bc,_hello_world,px -r %t.bc,_percent_s,px -r %t.bc,_foo,px %t.bc -o %t2.o 2>&1
28 ; RUN: llvm-nm %t2.o.0 | FileCheck %s --check-prefix=LTO-FREESTANDING
30 ; Test -lto-freestanding option for LTOBackend & new PM with custom pipeline.
32 ; RUN: llvm-lto2 run -use-new-pm -opt-pipeline='default<O3>' -r %t.bc,_fprintf,px -r %t.bc,_hello_world,px -r %t.bc,_percent_s,px -r %t.bc,_foo,px %t.bc -o %t1.o 2>&1
33 ; RUN: llvm-nm %t1.o.0 | FileCheck %s --check-prefix=LTO
35 ; RUN: llvm-lto2 run -use-new-pm -opt-pipeline='default<O3>' -lto-freestanding -r %t.bc,_fprintf,px -r %t.bc,_hello_world,px -r %t.bc,_percent_s,px -r %t.bc,_foo,px %t.bc -o %t2.o 2>&1
36 ; RUN: llvm-nm %t2.o.0 | FileCheck %s --check-prefix=LTO-FREESTANDING
39 target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
40 target triple = "x86_64-apple-macosx10.11.0"
42 declare i32 @fprintf(%FILE*, i8*, ...)
46 @hello_world = constant [13 x i8] c"hello world\0A\00"
47 @percent_s = constant [3 x i8] c"%s\00"
49 ; Check fprintf(fp, "%s", str) -> fwrite(str, fp) only when builtins are enabled
51 define void @foo(%FILE* %fp) {
52 %fmt = getelementptr [3 x i8], [3 x i8]* @percent_s, i32 0, i32 0
53 %str = getelementptr [13 x i8], [13 x i8]* @hello_world, i32 0, i32 0
54 call i32 (%FILE*, i8*, ...) @fprintf(%FILE* %fp, i8* %fmt, i8* %str)