[cfe-commits] r151745 - in /cfe/trunk: lib/CodeGen/BackendUtil.cpp test/CodeGen/libcalls-fno-builtin.c

Chad Rosier mcrosier at apple.com
Wed Feb 29 12:15:00 PST 2012


Author: mcrosier
Date: Wed Feb 29 14:14:59 2012
New Revision: 151745

URL: http://llvm.org/viewvc/llvm-project?rev=151745&view=rev
Log:
Allocate TargetLibraryInfo for the CodeGen passes.  Otherwise, it's instantiated
by the BAA pass, which uses the default TargetLibraryInfo constructor.
Unfortunately, the default TargetLibraryInfo constructor assumes all library
calls are available and thus ignores -fno-builtin.
rdar://10947759

Added:
    cfe/trunk/test/CodeGen/libcalls-fno-builtin.c
Modified:
    cfe/trunk/lib/CodeGen/BackendUtil.cpp

Modified: cfe/trunk/lib/CodeGen/BackendUtil.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/BackendUtil.cpp?rev=151745&r1=151744&r2=151745&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/BackendUtil.cpp (original)
+++ cfe/trunk/lib/CodeGen/BackendUtil.cpp Wed Feb 29 14:14:59 2012
@@ -351,6 +351,12 @@
   // Create the code generator passes.
   PassManager *PM = getCodeGenPasses();
 
+  // Add LibraryInfo.
+  TargetLibraryInfo *TLI = new TargetLibraryInfo();
+  if (!CodeGenOpts.SimplifyLibCalls)
+    TLI->disableAllFunctions();
+  PM->add(TLI);
+
   // Normal mode, emit a .s or .o file by running the code generator. Note,
   // this also adds codegenerator level optimization passes.
   TargetMachine::CodeGenFileType CGFT = TargetMachine::CGFT_AssemblyFile;

Added: cfe/trunk/test/CodeGen/libcalls-fno-builtin.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/libcalls-fno-builtin.c?rev=151745&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/libcalls-fno-builtin.c (added)
+++ cfe/trunk/test/CodeGen/libcalls-fno-builtin.c Wed Feb 29 14:14:59 2012
@@ -0,0 +1,27 @@
+// RUN: %clang_cc1 -S -O3 -fno-builtin -o - %s | FileCheck %s
+
+double ceil(double x);
+double copysign(double,double);
+double cos(double x);
+double fabs(double x);
+double floor(double x);
+
+double t1(double x) { return ceil(x); }
+// CHECK: t1
+// CHECK: ceil
+
+double t2(double x, double y) { return copysign(x,y); }
+// CHECK: t2
+// CHECK: copysign
+
+double t3(double x) { return cos(x); }
+// CHECK: t3
+// CHECK: cos
+
+double t4(double x) { return fabs(x); }
+// CHECK: t4
+// CHECK: fabs
+
+double t5(double x) { return floor(x); }
+// CHECK: t5
+// CHECK: floor





More information about the cfe-commits mailing list