[cfe-commits] r85278 - in /cfe/trunk: lib/CodeGen/CGCall.cpp test/CodeGen/function-attributes.c
Daniel Dunbar
daniel at zuster.org
Tue Oct 27 12:48:09 PDT 2009
Author: ddunbar
Date: Tue Oct 27 14:48:08 2009
New Revision: 85278
URL: http://llvm.org/viewvc/llvm-project?rev=85278&view=rev
Log:
Set OptimizeForSize LLVM function attribute with -Os.
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
cfe/trunk/test/CodeGen/function-attributes.c
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=85278&r1=85277&r2=85278&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Tue Oct 27 14:48:08 2009
@@ -441,6 +441,8 @@
RetAttrs |= llvm::Attribute::NoAlias;
}
+ if (CompileOpts.OptimizeSize)
+ FuncAttrs |= llvm::Attribute::OptimizeForSize;
if (CompileOpts.DisableRedZone)
FuncAttrs |= llvm::Attribute::NoRedZone;
if (CompileOpts.NoImplicitFloat)
Modified: cfe/trunk/test/CodeGen/function-attributes.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/function-attributes.c?rev=85278&r1=85277&r2=85278&view=diff
==============================================================================
--- cfe/trunk/test/CodeGen/function-attributes.c (original)
+++ cfe/trunk/test/CodeGen/function-attributes.c Tue Oct 27 14:48:08 2009
@@ -1,4 +1,4 @@
-// RUN: clang-cc -triple i386-unknown-unknown -emit-llvm -o - %s | FileCheck %s
+// RUN: clang-cc -triple i386-unknown-unknown -emit-llvm -Os -o - %s | FileCheck %s
// CHECK: define signext i8 @f0(i32 %x) nounwind
// CHECK: define zeroext i8 @f1(i32 %x) nounwind
// CHECK: define void @f2(i8 signext %x) nounwind
@@ -24,15 +24,22 @@
void f7(unsigned short x) { }
-// CHECK: define void @f8() nounwind alwaysinline
+// CHECK: define void @f8()
+// CHECK: nounwind
+// CHECK: alwaysinline
+// CHECK: {
void __attribute__((always_inline)) f8(void) { }
-// CHECK: call void @f9_t() noreturn
+// CHECK: call void @f9_t()
+// CHECK: noreturn
+// CHECK: {
void __attribute__((noreturn)) f9_t(void);
void f9(void) { f9_t(); }
// FIXME: We should be setting nounwind on calls.
-// CHECK: call i32 @f10_t() readnone
+// CHECK: call i32 @f10_t()
+// CHECK: readnone
+// CHECK: {
int __attribute__((const)) f10_t(void);
int f10(void) { return f10_t(); }
int f11(void) {
@@ -49,9 +56,9 @@
// Ensure that these get inlined: rdar://6853279
-// CHECK: define i32 @f14
+// CHECK: define void @f14
// CHECK-NOT: @ai_
-// CHECK: ret i32
+// CHECK: call void @f14_end
static __inline__ __attribute__((always_inline))
int ai_1() { return 4; }
@@ -60,7 +67,17 @@
int a, b, c, d, e;
} ai_2() { while (1) {} }
-int f14() {
- ai_2();
- return ai_1();
+void f14(int a) {
+ extern void f14_end(void);
+ if (a)
+ ai_2();
+ ai_1();
+ f14_end();
+}
+
+// <rdar://problem/7102668> [irgen] clang isn't setting the optsize bit on functions
+// CHECK: define void @f15
+// CHECK: optsize
+// CHECK: {
+void f15(void) {
}
More information about the cfe-commits
mailing list