Change ForceSizeOpt attribute into MinSize attribute
authorQuentin Colombet <qcolombet@apple.com>
Tue, 30 Oct 2012 16:32:52 +0000 (16:32 +0000)
committerQuentin Colombet <qcolombet@apple.com>
Tue, 30 Oct 2012 16:32:52 +0000 (16:32 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@167020 91177308-0d34-0410-b5e6-96231b3b80d8

include/llvm/Attributes.h
lib/AsmParser/LLLexer.cpp
lib/AsmParser/LLParser.cpp
lib/AsmParser/LLToken.h
lib/Target/ARM/ARMISelLowering.cpp
lib/Target/CppBackend/CPPBackend.cpp
lib/VMCore/Attributes.cpp
test/CodeGen/ARM/call-noret-forsize.ll [deleted file]
test/CodeGen/ARM/call-noret-minsize.ll [new file with mode: 0644]
test/Feature/forceoptsize_attr.ll [deleted file]
test/Feature/minsize_attr.ll [new file with mode: 0644]

index 5350e3ea2dce8642c3607c060b931ff150511220..5ace200803eb05ed02845877801eee8a5dbfcdb0 100644 (file)
@@ -58,9 +58,9 @@ public:
                            ///< 0 means unaligned different from align 1
     AlwaysInline,          ///< inline=always
     ByVal,                 ///< Pass structure by value
-    ForceSizeOpt,          ///< Function must be optimized for size first
     InlineHint,            ///< Source said inlining was desirable
     InReg,                 ///< Force argument to be passed in register
+    MinSize,               ///< Function must be optimized for size first
     Naked,                 ///< Naked function
     Nest,                  ///< Nested function static chain
     NoAlias,               ///< Considered to not alias after call
@@ -154,7 +154,7 @@ public:
       hasAttribute(Attributes::NonLazyBind) ||
       hasAttribute(Attributes::ReturnsTwice) ||
       hasAttribute(Attributes::AddressSafety) ||
-      hasAttribute(Attributes::ForceSizeOpt);
+      hasAttribute(Attributes::MinSize);
   }
 
   bool operator==(const Attributes &A) const {
@@ -266,7 +266,7 @@ public:
       .removeAttribute(Attributes::NonLazyBind)
       .removeAttribute(Attributes::ReturnsTwice)
       .removeAttribute(Attributes::AddressSafety)
-      .removeAttribute(Attributes::ForceSizeOpt);
+      .removeAttribute(Attributes::MinSize);
   }
 
   uint64_t Raw() const { return Bits; }
index 91f973d8d3973eabe6b7ca53d3db78616dec472a..a60e4aa41c425d2eef7de15d80eca6477ef25175 100644 (file)
@@ -558,7 +558,7 @@ lltok::Kind LLLexer::LexIdentifier() {
   KEYWORD(naked);
   KEYWORD(nonlazybind);
   KEYWORD(address_safety);
-  KEYWORD(forcesizeopt);
+  KEYWORD(minsize);
 
   KEYWORD(type);
   KEYWORD(opaque);
index 75fc16cd9560238bc43f2c4acc571a716ef10d31..ac803c57833467c33168b6bfefe6195fa526dd95 100644 (file)
@@ -953,7 +953,7 @@ bool LLParser::ParseOptionalAttrs(AttrBuilder &B, unsigned AttrKind) {
     case lltok::kw_naked:           B.addAttribute(Attributes::Naked); break;
     case lltok::kw_nonlazybind:     B.addAttribute(Attributes::NonLazyBind); break;
     case lltok::kw_address_safety:  B.addAttribute(Attributes::AddressSafety); break;
-    case lltok::kw_forcesizeopt:    B.addAttribute(Attributes::ForceSizeOpt); break;
+    case lltok::kw_minsize:         B.addAttribute(Attributes::MinSize); break;
 
     case lltok::kw_alignstack: {
       unsigned Alignment;
@@ -1012,7 +1012,7 @@ bool LLParser::ParseOptionalAttrs(AttrBuilder &B, unsigned AttrKind) {
     case lltok::kw_nonlazybind:
     case lltok::kw_returns_twice:
     case lltok::kw_address_safety:
-    case lltok::kw_forcesizeopt:
+    case lltok::kw_minsize:
       if (AttrKind != 2)
         HaveError |= Error(AttrLoc, "invalid use of function-only attribute");
       break;
index 6cffc52d17f76a89a482b3d007a6e1ee640ee48b..036686d31823834586a45b033d7418908a29a66f 100644 (file)
@@ -110,7 +110,7 @@ namespace lltok {
     kw_naked,
     kw_nonlazybind,
     kw_address_safety,
-    kw_forcesizeopt,
+    kw_minsize,
 
     kw_type,
     kw_opaque,
index e4bc31c48104324776c1a714ef9ae6911a556ac1..3b8d79be97bf21cede8ced823cb9c480600ee9ce 100644 (file)
@@ -1594,15 +1594,15 @@ ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
 
   // FIXME: handle tail calls differently.
   unsigned CallOpc;
-  bool HasForceSizeAttr = MF.getFunction()->getFnAttributes().
-                          hasAttribute(Attributes::ForceSizeOpt);
+  bool HasMinSizeAttr = MF.getFunction()->getFnAttributes().
+    hasAttribute(Attributes::MinSize);
   if (Subtarget->isThumb()) {
     if ((!isDirect || isARMFunc) && !Subtarget->hasV5TOps())
       CallOpc = ARMISD::CALL_NOLINK;
     else if (doesNotRet && isDirect && !isARMFunc &&
              Subtarget->hasRAS() && !Subtarget->isThumb1Only() &&
             // Emit regular call when code size is the priority
-            !HasForceSizeAttr)
+            !HasMinSizeAttr)
       // "mov lr, pc; b _foo" to avoid confusing the RSP
       CallOpc = ARMISD::CALL_NOLINK;
     else
@@ -1612,7 +1612,7 @@ ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
       CallOpc = ARMISD::CALL_NOLINK;
     } else if (doesNotRet && isDirect && Subtarget->hasRAS() &&
               // Emit regular call when code size is the priority
-              !HasForceSizeAttr)
+              !HasMinSizeAttr)
       // "mov lr, pc; b _foo" to avoid confusing the RSP
       CallOpc = ARMISD::CALL_NOLINK;
     else
index dd00b7d48bd16171e3cfdf68edc0e4eee16a4670..0f3efd8345026769090a549c26e36d18514fa4b2 100644 (file)
@@ -507,6 +507,7 @@ void CppWriter::printAttributes(const AttrListPtr &PAL,
       HANDLE_ATTR(ReturnsTwice);
       HANDLE_ATTR(UWTable);
       HANDLE_ATTR(NonLazyBind);
+      HANDLE_ATTR(MinSize);
 #undef HANDLE_ATTR
       if (attrs.hasAttribute(Attributes::StackAlignment))
         Out << "    B.addStackAlignmentAttr(" << attrs.getStackAlignment() << ")\n";
index 642d4fcffb8ba562cc39af70e5f78b0b1df51117..5a552c34e168f23f5e7be4680b912427336c9e29 100644 (file)
@@ -201,8 +201,8 @@ std::string Attributes::getAsString() const {
     Result += "nonlazybind ";
   if (hasAttribute(Attributes::AddressSafety))
     Result += "address_safety ";
-  if (hasAttribute(Attributes::ForceSizeOpt))
-    Result += "forcesizeopt ";
+  if (hasAttribute(Attributes::MinSize))
+    Result += "minsize ";
   if (hasAttribute(Attributes::StackAlignment)) {
     Result += "alignstack(";
     Result += utostr(getStackAlignment());
@@ -326,7 +326,7 @@ uint64_t AttributesImpl::getAttrMask(uint64_t Val) {
   case Attributes::UWTable:         return 1 << 30;
   case Attributes::NonLazyBind:     return 1U << 31;
   case Attributes::AddressSafety:   return 1ULL << 32;
-  case Attributes::ForceSizeOpt:    return 1ULL << 33;
+  case Attributes::MinSize:         return 1ULL << 33;
   }
   llvm_unreachable("Unsupported attribute type");
 }
diff --git a/test/CodeGen/ARM/call-noret-forsize.ll b/test/CodeGen/ARM/call-noret-forsize.ll
deleted file mode 100644 (file)
index 04643f5..0000000
+++ /dev/null
@@ -1,34 +0,0 @@
-; RUN: llc < %s -mtriple=armv7-apple-ios -mcpu=cortex-a8   | FileCheck %s -check-prefix=ARM
-; RUN: llc < %s -mtriple=armv7-apple-ios -mcpu=swift       | FileCheck %s -check-prefix=SWIFT
-; RUN: llc < %s -mtriple=thumbv7-apple-ios -mcpu=cortex-a8 | FileCheck %s -check-prefix=T2
-; rdar://12348580
-
-define void @t1() noreturn forcesizeopt nounwind ssp {
-entry:
-; ARM: t1:
-; ARM: bl _bar
-
-; SWIFT: t1:
-; SWIFT: bl _bar
-
-; T2: t1:
-; T2: blx _bar
-  tail call void @bar() noreturn nounwind
-  unreachable
-}
-
-define void @t2() noreturn forcesizeopt nounwind ssp {
-entry:
-; ARM: t2:
-; ARM: bl _t1
-
-; SWIFT: t2:
-; SWIFT: bl _t1
-
-; T2: t2:
-; T2: bl _t1
-  tail call void @t1() noreturn nounwind
-  unreachable
-}
-
-declare void @bar() noreturn
diff --git a/test/CodeGen/ARM/call-noret-minsize.ll b/test/CodeGen/ARM/call-noret-minsize.ll
new file mode 100644 (file)
index 0000000..35490ac
--- /dev/null
@@ -0,0 +1,34 @@
+; RUN: llc < %s -mtriple=armv7-apple-ios -mcpu=cortex-a8   | FileCheck %s -check-prefix=ARM
+; RUN: llc < %s -mtriple=armv7-apple-ios -mcpu=swift       | FileCheck %s -check-prefix=SWIFT
+; RUN: llc < %s -mtriple=thumbv7-apple-ios -mcpu=cortex-a8 | FileCheck %s -check-prefix=T2
+; rdar://12348580
+
+define void @t1() noreturn minsize nounwind ssp {
+entry:
+; ARM: t1:
+; ARM: bl _bar
+
+; SWIFT: t1:
+; SWIFT: bl _bar
+
+; T2: t1:
+; T2: blx _bar
+  tail call void @bar() noreturn nounwind
+  unreachable
+}
+
+define void @t2() noreturn minsize nounwind ssp {
+entry:
+; ARM: t2:
+; ARM: bl _t1
+
+; SWIFT: t2:
+; SWIFT: bl _t1
+
+; T2: t2:
+; T2: bl _t1
+  tail call void @t1() noreturn nounwind
+  unreachable
+}
+
+declare void @bar() noreturn
diff --git a/test/Feature/forceoptsize_attr.ll b/test/Feature/forceoptsize_attr.ll
deleted file mode 100644 (file)
index 89f2a5f..0000000
+++ /dev/null
@@ -1,7 +0,0 @@
-; RUN: llvm-as < %s | llvm-dis | FileCheck %s
-
-define void @test1() forcesizeopt {
-; CHECK: define void @test1() forcesizeopt
-        ret void
-}
-
diff --git a/test/Feature/minsize_attr.ll b/test/Feature/minsize_attr.ll
new file mode 100644 (file)
index 0000000..51b133c
--- /dev/null
@@ -0,0 +1,7 @@
+; RUN: llvm-as < %s | llvm-dis | FileCheck %s
+
+define void @test1() minsize {
+; CHECK: define void @test1() minsize
+        ret void
+}
+