[llvm-branch-commits] [llvm] 01c3135 - [LTO] Add test for freestanding LTO option.
Florian Hahn via llvm-branch-commits
llvm-branch-commits at lists.llvm.org
Wed Jan 13 12:48:26 PST 2021
Author: Florian Hahn
Date: 2021-01-13T20:43:22Z
New Revision: 01c3135850d15c8dce9374eec26dc2d555a87b7f
URL: https://github.com/llvm/llvm-project/commit/01c3135850d15c8dce9374eec26dc2d555a87b7f
DIFF: https://github.com/llvm/llvm-project/commit/01c3135850d15c8dce9374eec26dc2d555a87b7f.diff
LOG: [LTO] Add test for freestanding LTO option.
This patch adds a test for the -lto-freestanding option, similar to
llvm/test/ThinLTO/X86/tli-nobuiltin.ll.
Added:
llvm/test/LTO/X86/tli-nobuiltin.ll
Modified:
Removed:
################################################################################
diff --git a/llvm/test/LTO/X86/tli-nobuiltin.ll b/llvm/test/LTO/X86/tli-nobuiltin.ll
new file mode 100644
index 000000000000..4f6b3ef63f48
--- /dev/null
+++ b/llvm/test/LTO/X86/tli-nobuiltin.ll
@@ -0,0 +1,31 @@
+; Test -lto-freestanding option for libLTO.
+; RUN: llvm-as < %s > %t.bc
+
+; Regular run: expects fprintf to be turned into fwrite
+; RUN: llvm-lto %t.bc -exported-symbol=_foo -o %t.o
+; RUN: llvm-nm %t.o | FileCheck %s --check-prefix=LTO
+; LTO: fwrite
+
+; Freestanding run: expects fprintf to NOT be turned into fwrite
+; RUN: llvm-lto %t.bc -lto-freestanding -exported-symbol=_foo -o %t.o
+; RUN: llvm-nm %t.o | FileCheck %s --check-prefix=LTO-FREESTANDING
+; LTO-FREESTANDING: fprintf
+
+target datalayout = "e-m:o-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
+target triple = "x86_64-apple-macosx10.11.0"
+
+declare i32 @fprintf(%FILE*, i8*, ...)
+
+%FILE = type { }
+
+ at hello_world = constant [13 x i8] c"hello world\0A\00"
+ at percent_s = constant [3 x i8] c"%s\00"
+
+; Check fprintf(fp, "%s", str) -> fwrite(str, fp) only when builtins are enabled
+
+define void @foo(%FILE* %fp) {
+ %fmt = getelementptr [3 x i8], [3 x i8]* @percent_s, i32 0, i32 0
+ %str = getelementptr [13 x i8], [13 x i8]* @hello_world, i32 0, i32 0
+ call i32 (%FILE*, i8*, ...) @fprintf(%FILE* %fp, i8* %fmt, i8* %str)
+ ret void
+}
More information about the llvm-branch-commits
mailing list