aboutsummaryrefslogtreecommitdiffstats
path: root/test/LTO
diff options
context:
space:
mode:
authorJustin Bogner <mail@justinbogner.com>2013-11-12 21:44:01 +0000
committerJustin Bogner <mail@justinbogner.com>2013-11-12 21:44:01 +0000
commitdc6b4b4fc2665eea17684d29e4dae219b258b5ef (patch)
tree3098f3760218f627a65eb20fe6b2935d088dfe63 /test/LTO
parent59e648e3c8966e0678902a2994558f25c8573ce4 (diff)
downloadexternal_llvm-dc6b4b4fc2665eea17684d29e4dae219b258b5ef.zip
external_llvm-dc6b4b4fc2665eea17684d29e4dae219b258b5ef.tar.gz
external_llvm-dc6b4b4fc2665eea17684d29e4dae219b258b5ef.tar.bz2
Protect user-supplied runtime library functions in LTO
Add user-supplied C runtime and compiler-rt library functions to llvm.compiler.used to protect them from premature optimization by passes like -globalopt and -ipsccp. Calls to (seemingly unused) runtime library functions can be added by -instcombine and instruction lowering. Patch by Duncan Exon Smith, thanks! Fixes <rdar://problem/14740087> git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@194514 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/LTO')
-rw-r--r--test/LTO/runtime-library.ll27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/LTO/runtime-library.ll b/test/LTO/runtime-library.ll
new file mode 100644
index 0000000..76fc6f0
--- /dev/null
+++ b/test/LTO/runtime-library.ll
@@ -0,0 +1,27 @@
+; runtime library implementations should be added to llvm.compiler.used
+; RUN: llvm-as <%s >%t1
+; RUN: llvm-lto -o %t2 %t1
+; RUN: llvm-nm -no-sort %t2 | FileCheck %s -check-prefix=KEEP -check-prefix=LOSE
+
+target triple = "x86_64-apple-darwin9"
+
+; KEEP-LABEL: _puts
+define void @puts() {
+ ret void
+}
+
+; KEEP-LABEL: ___divti3
+define void @__divti3() {
+ ret void
+}
+
+; KEEP-LABEL: _memset
+define void @memset() {
+ ret void
+}
+
+; LOSE-NOT: _myprintf
+define void @myprintf() {
+ ret void
+}
+