summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Dunbar <daniel@zuster.org>2009-02-15 20:00:15 +0000
committerDaniel Dunbar <daniel@zuster.org>2009-02-15 20:00:15 +0000
commitf898638eee496756c73f2933f6a9f6f81c1b193d (patch)
tree4af1e4517dd2f0a967cb1177e7a78e898212d5a3
parentd9849254abfed92207f692f4b0b8b60b5d1e254e (diff)
downloadbcm5719-llvm-f898638eee496756c73f2933f6a9f6f81c1b193d.tar.gz
bcm5719-llvm-f898638eee496756c73f2933f6a9f6f81c1b193d.zip
PR3589: Don't simplify libcalls with -ffreestanding.
llvm-svn: 64599
-rw-r--r--clang/Driver/clang.cpp2
-rw-r--r--clang/test/CodeGen/PR3589-freestanding-libcalls.c9
2 files changed, 10 insertions, 1 deletions
diff --git a/clang/Driver/clang.cpp b/clang/Driver/clang.cpp
index 2f7ce69ee39..d1ef871d6a1 100644
--- a/clang/Driver/clang.cpp
+++ b/clang/Driver/clang.cpp
@@ -1271,7 +1271,7 @@ static void InitializeCompileOptions(CompileOptions &Opts) {
// FIXME: There are llvm-gcc options to control these selectively.
Opts.InlineFunctions = (Opts.OptimizationLevel > 1);
Opts.UnrollLoops = (Opts.OptimizationLevel > 1 && !OptSize);
- Opts.SimplifyLibCalls = 1;
+ Opts.SimplifyLibCalls = !Freestanding;
#ifdef NDEBUG
Opts.VerifyModule = 0;
diff --git a/clang/test/CodeGen/PR3589-freestanding-libcalls.c b/clang/test/CodeGen/PR3589-freestanding-libcalls.c
new file mode 100644
index 00000000000..61852e3c49b
--- /dev/null
+++ b/clang/test/CodeGen/PR3589-freestanding-libcalls.c
@@ -0,0 +1,9 @@
+// RUN: clang -emit-llvm %s -o - | grep 'declare i32 @printf' | count 1 &&
+// RUN: clang -O2 -emit-llvm %s -o - | grep 'declare i32 @puts' | count 1 &&
+// RUN: clang -ffreestanding -O2 -emit-llvm %s -o - | grep 'declare i32 @puts' | count 0
+
+#include <stdio.h>
+
+void f0() {
+ printf("hello\n");
+}
OpenPOWER on IntegriCloud