]> granicus.if.org Git - clang/commitdiff
PR3589: Don't simplify libcalls with -ffreestanding.
authorDaniel Dunbar <daniel@zuster.org>
Sun, 15 Feb 2009 20:00:15 +0000 (20:00 +0000)
committerDaniel Dunbar <daniel@zuster.org>
Sun, 15 Feb 2009 20:00:15 +0000 (20:00 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64599 91177308-0d34-0410-b5e6-96231b3b80d8

Driver/clang.cpp
test/CodeGen/PR3589-freestanding-libcalls.c [new file with mode: 0644]

index 2f7ce69ee3916bfcdb3a553ed21bed83e18af999..d1ef871d6a11fa42fe35875880bb3116a5ac2709 100644 (file)
@@ -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/test/CodeGen/PR3589-freestanding-libcalls.c b/test/CodeGen/PR3589-freestanding-libcalls.c
new file mode 100644 (file)
index 0000000..61852e3
--- /dev/null
@@ -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");
+}