• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; Test -lto-freestanding option for libLTO.
2; RUN: llvm-as < %s > %t.bc
3
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
7; LTO: fwrite
8
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
13
14; Same with ThinLTO now.
15; RUN: opt -module-hash -module-summary %s -o %t.bc
16
17; Regular run: expects fprintf to be turned into fwrite
18; RUN: llvm-lto -exported-symbol=_foo -thinlto-action=run %t.bc
19; RUN: llvm-nm %t.bc.thinlto.o | FileCheck %s --check-prefix=ThinLTO
20; ThinLTO: fwrite
21
22; Freestanding run: expects fprintf to NOT be turned into fwrite
23; RUN: llvm-lto -lto-freestanding -exported-symbol=_foo -thinlto-action=run %t.bc
24; RUN: llvm-nm %t.bc.thinlto.o | FileCheck %s --check-prefix=ThinLTO-FREESTANDING
25; ThinLTO-FREESTANDING: fprintf
26
27
28target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
29target triple = "x86_64-apple-macosx10.11.0"
30
31declare i32 @fprintf(%FILE*, i8*, ...)
32
33%FILE = type { }
34
35@hello_world = constant [13 x i8] c"hello world\0A\00"
36@percent_s = constant [3 x i8] c"%s\00"
37
38; Check fprintf(fp, "%s", str) -> fwrite(str, fp) only when builtins are enabled
39
40define void @foo(%FILE* %fp) {
41  %fmt = getelementptr [3 x i8], [3 x i8]* @percent_s, i32 0, i32 0
42  %str = getelementptr [13 x i8], [13 x i8]* @hello_world, i32 0, i32 0
43  call i32 (%FILE*, i8*, ...) @fprintf(%FILE* %fp, i8* %fmt, i8* %str)
44  ret void
45}
46
47