From 3ada6ffd92e02b02f1cdb3c2044aab24dbe0b755 Mon Sep 17 00:00:00 2001 From: Daniel Dunbar Date: Sun, 15 Feb 2009 20:00:15 +0000 Subject: [PATCH] PR3589: Don't simplify libcalls with -ffreestanding. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@64599 91177308-0d34-0410-b5e6-96231b3b80d8 --- Driver/clang.cpp | 2 +- test/CodeGen/PR3589-freestanding-libcalls.c | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) create mode 100644 test/CodeGen/PR3589-freestanding-libcalls.c diff --git a/Driver/clang.cpp b/Driver/clang.cpp index 2f7ce69ee3..d1ef871d6a 100644 --- a/Driver/clang.cpp +++ b/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/test/CodeGen/PR3589-freestanding-libcalls.c b/test/CodeGen/PR3589-freestanding-libcalls.c new file mode 100644 index 0000000000..61852e3c49 --- /dev/null +++ b/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 + +void f0() { + printf("hello\n"); +} -- 2.50.1