<br><br><div class="gmail_quote">On Fri, Nov 2, 2012 at 12:55 AM, Quentin Colombet <span dir="ltr"><<a href="mailto:qcolombet@apple.com" target="_blank">qcolombet@apple.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Author: qcolombet<br>
Date: Thu Nov  1 18:55:47 2012<br>
New Revision: 167266<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=167266&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=167266&view=rev</a><br>
Log:<br>
Update the front end to use minsize attribute<br>
<br>
Added:<br>
    cfe/trunk/test/CodeGen/attr-minsize.cpp<br>
      - copied, changed from r167249, cfe/trunk/test/CodeGen/attr-minsize.c<br>
    cfe/trunk/test/CodeGenObjC/attr-minsize.m<br>
    cfe/trunk/test/Sema/attr-minsize.c<br>
Removed:<br>
    cfe/trunk/test/CodeGen/attr-minsize.c<br>
Modified:<br>
    cfe/trunk/include/clang/Basic/Attr.td<br>
    cfe/trunk/lib/CodeGen/CodeGenModule.cpp<br>
    cfe/trunk/lib/Sema/SemaDeclAttr.cpp<br>
<br>
Modified: cfe/trunk/include/clang/Basic/Attr.td<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=167266&r1=167265&r2=167266&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/include/clang/Basic/Attr.td?rev=167266&r1=167265&r2=167266&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/include/clang/Basic/Attr.td (original)<br>
+++ cfe/trunk/include/clang/Basic/Attr.td Thu Nov  1 18:55:47 2012<br>
@@ -341,6 +341,11 @@<br>
   let SemaHandler = 0;<br>
 }<br>
<br>
+def MinSize : InheritableAttr {<br>
+  let Spellings = [GNU<"minsize">];<br>
+  let Subjects = [Function];<br>
+}<br>
+<br>
 def Format : InheritableAttr {<br>
   let Spellings = [GNU<"format">];<br>
   let Args = [StringArgument<"Type">, IntArgument<"FormatIdx">,<br>
<br>
Modified: cfe/trunk/lib/CodeGen/CodeGenModule.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=167266&r1=167265&r2=167266&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/CodeGen/CodeGenModule.cpp?rev=167266&r1=167265&r2=167266&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/CodeGen/CodeGenModule.cpp (original)<br>
+++ cfe/trunk/lib/CodeGen/CodeGenModule.cpp Thu Nov  1 18:55:47 2012<br>
@@ -583,6 +583,9 @@<br>
   if (D->hasAttr<ColdAttr>())<br>
     F->addFnAttr(llvm::Attributes::OptimizeForSize);<br>
<br>
+  if (D->hasAttr<MinSizeAttr>())<br>
+    F->addFnAttr(llvm::Attributes::MinSize);<br>
+<br>
   if (isa<CXXConstructorDecl>(D) || isa<CXXDestructorDecl>(D))<br>
     F->setUnnamedAddr(true);<br>
<br>
<br>
Modified: cfe/trunk/lib/Sema/SemaDeclAttr.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=167266&r1=167265&r2=167266&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaDeclAttr.cpp?rev=167266&r1=167265&r2=167266&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/lib/Sema/SemaDeclAttr.cpp (original)<br>
+++ cfe/trunk/lib/Sema/SemaDeclAttr.cpp Thu Nov  1 18:55:47 2012<br>
@@ -1523,6 +1523,20 @@<br>
                                          Str->getString()));<br>
 }<br>
<br>
+static void handleMinSizeAttr(Sema &S, Decl *D, const AttributeList &Attr) {<br>
+  // Check the attribute arguments.<br>
+  if (!checkAttributeNumArgs(S, Attr, 0))<br>
+    return;<br>
+<br>
+  if (!isa<FunctionDecl>(D) && !isa<ObjCMethodDecl>(D)) {<br>
+    S.Diag(Attr.getLoc(), diag::err_attribute_wrong_decl_type)<br>
+      << Attr.getName() << ExpectedFunctionOrMethod;<br>
+    return;<br>
+  }<br>
+<br>
+  D->addAttr(::new (S.Context) MinSizeAttr(Attr.getRange(), S.Context));<br>
+}<br>
+<br>
 static void handleColdAttr(Sema &S, Decl *D, const AttributeList &Attr) {<br>
   // Check the attribute arguments.<br>
   if (!checkAttributeNumArgs(S, Attr, 0))<br>
@@ -4285,6 +4299,9 @@<br>
   case AttributeList::AT_ExtVectorType:<br>
     handleExtVectorTypeAttr(S, scope, D, Attr);<br>
     break;<br>
+  case AttributeList::AT_MinSize:<br>
+    handleMinSizeAttr(S, D, Attr);<br>
+    break;<br>
   case AttributeList::AT_Format:      handleFormatAttr      (S, D, Attr); break;<br>
   case AttributeList::AT_FormatArg:   handleFormatArgAttr   (S, D, Attr); break;<br>
   case AttributeList::AT_CUDAGlobal:  handleGlobalAttr      (S, D, Attr); break;<br>
<br>
Removed: cfe/trunk/test/CodeGen/attr-minsize.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-minsize.c?rev=167265&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-minsize.c?rev=167265&view=auto</a><br>

==============================================================================<br>
--- cfe/trunk/test/CodeGen/attr-minsize.c (original)<br>
+++ cfe/trunk/test/CodeGen/attr-minsize.c (removed)<br>
@@ -1,26 +0,0 @@<br>
-// RUN: %clang_cc1 -Oz -emit-llvm %s -o - | FileCheck %s -check-prefix=Oz<br>
-// RUN: %clang_cc1 -O0 -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER<br>
-// RUN: %clang_cc1 -O1 -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER<br>
-// RUN: %clang_cc1 -O2 -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER<br>
-// RUN: %clang_cc1 -O3 -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER<br>
-// RUN: %clang_cc1 -Os -emit-llvm %s -o - | FileCheck %s -check-prefix=OTHER<br>
-// Check that we set the minsize attribute on each function<br>
-// when Oz optimization level is set.<br>
-<br>
-int test1() {<br>
-  return 42;<br>
-// Oz: @test1{{.*}}minsize<br>
-// Oz: ret<br>
-// OTHER: @test1<br>
-// OTHER-NOT: minsize<br>
-// OTHER: ret<br>
-}<br>
-<br>
-int test2() {<br>
-  return 42;<br>
-// Oz: @test2{{.*}}minsize<br>
-// Oz: ret<br>
-// OTHER: @test2<br>
-// OTHER-NOT: minsize<br>
-// OTHER: ret<br>
-}<br>
<br>
Copied: cfe/trunk/test/CodeGen/attr-minsize.cpp (from r167249, cfe/trunk/test/CodeGen/attr-minsize.c)<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-minsize.cpp?p2=cfe/trunk/test/CodeGen/attr-minsize.cpp&p1=cfe/trunk/test/CodeGen/attr-minsize.c&r1=167249&r2=167266&rev=167266&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGen/attr-minsize.cpp?p2=cfe/trunk/test/CodeGen/attr-minsize.cpp&p1=cfe/trunk/test/CodeGen/attr-minsize.c&r1=167249&r2=167266&rev=167266&view=diff</a><br>

==============================================================================<br>
--- cfe/trunk/test/CodeGen/attr-minsize.c (original)<br>
+++ cfe/trunk/test/CodeGen/attr-minsize.cpp Thu Nov  1 18:55:47 2012<br>
@@ -9,18 +9,67 @@<br>
<br>
 int test1() {<br>
   return 42;<br>
-// Oz: @test1{{.*}}minsize<br>
+// Oz: @{{.*}}test1{{.*}}minsize<br>
 // Oz: ret<br>
-// OTHER: @test1<br>
+// OTHER: @{{.*}}test1<br>
 // OTHER-NOT: minsize<br>
 // OTHER: ret<br>
 }<br>
<br>
 int test2() {<br>
   return 42;<br>
-// Oz: @test2{{.*}}minsize<br>
+// Oz: @{{.*}}test2{{.*}}minsize<br>
 // Oz: ret<br>
-// OTHER: @test2<br>
+// OTHER: @{{.*}}test2<br>
 // OTHER-NOT: minsize<br>
 // OTHER: ret<br>
 }<br>
+<br>
+__attribute__((minsize))<br>
+int test3() {<br>
+  return 42;<br>
+// Oz: @{{.*}}test3{{.*}}minsize<br>
+// OTHER: @{{.*}}test3{{.*}}minsize<br>
+}<br>
+<br>
+// Check that the minsize attribute is well propagated through<br>
+// template instantiation<br>
+<br>
+template<typename T><br>
+__attribute__((minsize))<br>
+void test4(T arg) {<br>
+  return;<br>
+}<br>
+<br>
+template<br>
+void test4<int>(int arg);<br>
+// Oz: define{{.*}}void @{{.*}}test4<br>
+// Oz: minsize<br>
+// OTHER: define{{.*}}void @{{.*}}test4<br>
+// OTHER: minsize<br>
+<br>
+template<br>
+void test4<float>(float arg);<br>
+// Oz: define{{.*}}void @{{.*}}test4<br>
+// Oz: minsize<br>
+// OTHER: define{{.*}}void @{{.*}}test4<br>
+// OTHER: minsize<br>
+<br>
+template<typename T><br>
+void test5(T arg) {<br>
+  return;<br>
+}<br>
+<br>
+template<br>
+void test5<int>(int arg);<br>
+// Oz: define{{.*}}void @{{.*}}test5<br>
+// Oz: minsize<br>
+// OTHER: define{{.*}}void @{{.*}}test5<br>
+// OTHER-NOT: minsize<br>
+<br>
+template<br>
+void test5<float>(float arg);<br>
+// Oz: define{{.*}}void @{{.*}}test5<br>
+// Oz: minsize<br>
+// OTHER: define{{.*}}void @{{.*}}test5<br>
+// OTHER-NOT: minsize<br>
<br>
Added: cfe/trunk/test/CodeGenObjC/attr-minsize.m<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/attr-minsize.m?rev=167266&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/CodeGenObjC/attr-minsize.m?rev=167266&view=auto</a><br>

==============================================================================<br>
--- cfe/trunk/test/CodeGenObjC/attr-minsize.m (added)<br>
+++ cfe/trunk/test/CodeGenObjC/attr-minsize.m Thu Nov  1 18:55:47 2012<br>
@@ -0,0 +1,12 @@<br>
+// RUN: %clang_cc1 -emit-llvm -o - %s | FileCheck %s<br>
+<br>
+@interface Test<br>
+- (void)test;<br>
+@end<br>
+<br>
+@implementation Test<br>
+- (void)test __attribute__((minsize)) {<br>
+    // CHECK: define{{.*}}Test test<br>
+    // CHECK: minsize<br>
+}<br>
+@end<br>
<br>
Added: cfe/trunk/test/Sema/attr-minsize.c<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-minsize.c?rev=167266&view=auto" target="_blank">http://llvm.org/viewvc/llvm-project/cfe/trunk/test/Sema/attr-minsize.c?rev=167266&view=auto</a><br>

==============================================================================<br>
--- cfe/trunk/test/Sema/attr-minsize.c (added)<br>
+++ cfe/trunk/test/Sema/attr-minsize.c Thu Nov  1 18:55:47 2012<br>
@@ -0,0 +1,5 @@<br>
+// RUN: %clang_cc1 -fsyntax-only -verify %s<br>
+<br>
+int foo() __attribute__((__minsize__));<br>
+<br>
+int var1 __attribute__((__minsize__)); // expected-error{{'__minsize__' attribute only applies to functions and methods}}<br>
<br>
<br>
_______________________________________________<br>
cfe-commits mailing list<br>
<a href="mailto:cfe-commits@cs.uiuc.edu">cfe-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-commits</a><br>
</blockquote></div><br>Once you have committed the patch, please reply to the "review" thread with something like "Committed as r167266" so that the people who had an eye on the thread can now bury it and focus on new review threads :)<br>
<br>-- Matthieu<br>