47 lines · plain
1; Test -lto-freestanding option for libLTO.2; RUN: llvm-as < %s > %t.bc3 4; Regular run: expects fprintf to be turned into fwrite5; RUN: llvm-lto %t.bc -exported-symbol=_foo -o %t.o6; RUN: llvm-nm %t.o | FileCheck %s --check-prefix=LTO7; LTO: fwrite8 9; Freestanding run: expects fprintf to NOT be turned into fwrite10; RUN: llvm-lto %t.bc -lto-freestanding -exported-symbol=_foo -o %t.o11; RUN: llvm-nm %t.o | FileCheck %s --check-prefix=LTO-FREESTANDING12; LTO-FREESTANDING: fprintf13 14; Test -lto-freestanding option for LTOBackend15 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>&117; RUN: llvm-nm %t1.o.0 | FileCheck %s --check-prefix=LTO18 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>&120; RUN: llvm-nm %t2.o.0 | FileCheck %s --check-prefix=LTO-FREESTANDING21 22; Test -lto-freestanding option for LTOBackend with custom pipeline.23 24; RUN: llvm-lto2 run -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>&125; RUN: llvm-nm %t1.o.0 | FileCheck %s --check-prefix=LTO26 27; RUN: llvm-lto2 run -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>&128; RUN: llvm-nm %t2.o.0 | FileCheck %s --check-prefix=LTO-FREESTANDING29 30 31target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"32target triple = "x86_64-apple-macosx10.11.0"33 34declare i32 @fprintf(ptr, ptr, ...)35 36%FILE = type { }37 38@hello_world = constant [13 x i8] c"hello world\0A\00"39@percent_s = constant [3 x i8] c"%s\00"40 41; Check fprintf(fp, "%s", str) -> fwrite(str, fp) only when builtins are enabled42 43define void @foo(ptr %fp) {44 call i32 (ptr, ptr, ...) @fprintf(ptr %fp, ptr @percent_s, ptr @hello_world)45 ret void46}47