[cfe-commits] r166744 - in /cfe/trunk: lib/CodeGen/CGCall.cpp test/CodeGen/attr-forcesizeopt.c
Quentin Colombet
qcolombet at apple.com
Thu Oct 25 17:29:48 PDT 2012
Author: qcolombet
Date: Thu Oct 25 19:29:48 2012
New Revision: 166744
URL: http://llvm.org/viewvc/llvm-project?rev=166744&view=rev
Log:
Oz optimization level sets ForceSizeOpt attribute for each function
Added:
cfe/trunk/test/CodeGen/attr-forcesizeopt.c
Modified:
cfe/trunk/lib/CodeGen/CGCall.cpp
Modified: cfe/trunk/lib/CodeGen/CGCall.cpp
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CGCall.cpp?rev=166744&r1=166743&r2=166744&view=diff
==============================================================================
--- cfe/trunk/lib/CodeGen/CGCall.cpp (original)
+++ cfe/trunk/lib/CodeGen/CGCall.cpp Thu Oct 25 19:29:48 2012
@@ -968,6 +968,8 @@
if (CodeGenOpts.OptimizeSize)
FuncAttrs.addAttribute(llvm::Attributes::OptimizeForSize);
+ if (CodeGenOpts.OptimizeSize == 2)
+ FuncAttrs.addAttribute(llvm::Attributes::ForceSizeOpt);
if (CodeGenOpts.DisableRedZone)
FuncAttrs.addAttribute(llvm::Attributes::NoRedZone);
if (CodeGenOpts.NoImplicitFloat)
Added: cfe/trunk/test/CodeGen/attr-forcesizeopt.c
URL: http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-forcesizeopt.c?rev=166744&view=auto
==============================================================================
--- cfe/trunk/test/CodeGen/attr-forcesizeopt.c (added)
+++ cfe/trunk/test/CodeGen/attr-forcesizeopt.c Thu Oct 25 19:29:48 2012
@@ -0,0 +1,26 @@
+// RUN: %clang_cc1 -Oz -emit-llvm %s -o - | FileCheck %s -check-prefix=Oz
+// RUN: %clang_cc1 -O0 -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER
+// RUN: %clang_cc1 -O1 -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER
+// RUN: %clang_cc1 -O2 -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER
+// RUN: %clang_cc1 -O3 -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER
+// RUN: %clang_cc1 -Os -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER
+// Check that we set the forcesizeopt attribute on each function
+// when Oz optimization level is set.
+
+int test1() {
+ return 42;
+// Oz: @test1{{.*}}forcesizeopt
+// Oz: ret
+// OTHER: @test1
+// OTHER-NOT: forcesizeopt
+// OTHER: ret
+}
+
+int test2() {
+ return 42;
+// Oz: @test2{{.*}}forcesizeopt
+// Oz: ret
+// OTHER: @test2
+// OTHER-NOT: forcesizeopt
+// OTHER: ret
+}
More information about the cfe-commits
mailing list