[llvm-commits] [llvm] r166422 - in /llvm/trunk: include/llvm/Attributes.h lib/AsmParser/LLLexer.cpp lib/AsmParser/LLParser.cpp lib/AsmParser/LLToken.h lib/VMCore/Attributes.cpp
Chandler Carruth
chandlerc at google.com
Mon Oct 22 12:56:09 PDT 2012
On Mon, Oct 22, 2012 at 10:33 AM, Nadav Rotem <nrotem at apple.com> wrote:
> Author: nadav
> Date: Mon Oct 22 12:33:31 2012
> New Revision: 166422
>
> URL: http://llvm.org/viewvc/llvm-project?rev=166422&view=rev
> Log:
> Add the "ForceSizeOpt" attribute.
>
> Patch by Quentin Colombet <qcolombet at apple.com>
>
> Original description:
> """
> The attached patch is the first step to have a better control on Oz related optimizations.
> The Oz optimization level focuses on code size, thus I propose to add an attribute called ForceSizeOpt.
> """
So, Quentin, sorry I didn't see your original email, but I think
ForceSizeOpt is the wrong name here.
-Oz isn't about *forcing* the size-opt use case. It doesn't override
anything, etc. It's about how we optimize for size.
-Os --> When we could get performance at a significant cost to size,
don't go after that performance. That said, don't actively degrade
performance just to get size.
-Oz --> Actively degrade performance to shrink the code.
The important difference is that -Os should not really make code any
slower than -O0 or even -O1. On the other hand -Oz might actively slow
code down, and do other crazy things just to achieve a size reduction.
I would call this something more like "MinSizeOpt" or in prose
"optimize and minimize size" as opposed to "SizeOpt" and "optimize
without growing size".
>
>
> Modified:
> llvm/trunk/include/llvm/Attributes.h
> llvm/trunk/lib/AsmParser/LLLexer.cpp
> llvm/trunk/lib/AsmParser/LLParser.cpp
> llvm/trunk/lib/AsmParser/LLToken.h
> llvm/trunk/lib/VMCore/Attributes.cpp
>
> Modified: llvm/trunk/include/llvm/Attributes.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Attributes.h?rev=166422&r1=166421&r2=166422&view=diff
> ==============================================================================
> --- llvm/trunk/include/llvm/Attributes.h (original)
> +++ llvm/trunk/include/llvm/Attributes.h Mon Oct 22 12:33:31 2012
> @@ -84,7 +84,8 @@
> StackProtectReq = 24, ///< Stack protection required.
> StructRet = 25, ///< Hidden pointer to structure to return
> UWTable = 26, ///< Function must be in a unwind table
> - ZExt = 27 ///< Zero extended before/after call
> + ZExt = 27, ///< Zero extended before/after call
> + ForceSizeOpt = 28 ///< Function must be optimized for size first
> };
> private:
> AttributesImpl *Attrs;
> @@ -152,7 +153,8 @@
> hasAttribute(Attributes::UWTable) ||
> hasAttribute(Attributes::NonLazyBind) ||
> hasAttribute(Attributes::ReturnsTwice) ||
> - hasAttribute(Attributes::AddressSafety);
> + hasAttribute(Attributes::AddressSafety) ||
> + hasAttribute(Attributes::ForceSizeOpt);
> }
>
> bool operator==(const Attributes &A) const {
> @@ -263,7 +265,8 @@
> .removeAttribute(Attributes::UWTable)
> .removeAttribute(Attributes::NonLazyBind)
> .removeAttribute(Attributes::ReturnsTwice)
> - .removeAttribute(Attributes::AddressSafety);
> + .removeAttribute(Attributes::AddressSafety)
> + .removeAttribute(Attributes::ForceSizeOpt);
> }
>
> uint64_t Raw() const { return Bits; }
>
> Modified: llvm/trunk/lib/AsmParser/LLLexer.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLLexer.cpp?rev=166422&r1=166421&r2=166422&view=diff
> ==============================================================================
> --- llvm/trunk/lib/AsmParser/LLLexer.cpp (original)
> +++ llvm/trunk/lib/AsmParser/LLLexer.cpp Mon Oct 22 12:33:31 2012
> @@ -557,6 +557,7 @@
> KEYWORD(naked);
> KEYWORD(nonlazybind);
> KEYWORD(address_safety);
> + KEYWORD(forcesizeopt);
>
> KEYWORD(type);
> KEYWORD(opaque);
>
> Modified: llvm/trunk/lib/AsmParser/LLParser.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLParser.cpp?rev=166422&r1=166421&r2=166422&view=diff
> ==============================================================================
> --- llvm/trunk/lib/AsmParser/LLParser.cpp (original)
> +++ llvm/trunk/lib/AsmParser/LLParser.cpp Mon Oct 22 12:33:31 2012
> @@ -953,6 +953,7 @@
> 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_alignstack: {
> unsigned Alignment;
> @@ -1011,6 +1012,7 @@
> case lltok::kw_nonlazybind:
> case lltok::kw_returns_twice:
> case lltok::kw_address_safety:
> + case lltok::kw_forcesizeopt:
> if (AttrKind != 2)
> HaveError |= Error(AttrLoc, "invalid use of function-only attribute");
> break;
>
> Modified: llvm/trunk/lib/AsmParser/LLToken.h
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/AsmParser/LLToken.h?rev=166422&r1=166421&r2=166422&view=diff
> ==============================================================================
> --- llvm/trunk/lib/AsmParser/LLToken.h (original)
> +++ llvm/trunk/lib/AsmParser/LLToken.h Mon Oct 22 12:33:31 2012
> @@ -109,6 +109,7 @@
> kw_naked,
> kw_nonlazybind,
> kw_address_safety,
> + kw_forcesizeopt,
>
> kw_type,
> kw_opaque,
>
> Modified: llvm/trunk/lib/VMCore/Attributes.cpp
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/Attributes.cpp?rev=166422&r1=166421&r2=166422&view=diff
> ==============================================================================
> --- llvm/trunk/lib/VMCore/Attributes.cpp (original)
> +++ llvm/trunk/lib/VMCore/Attributes.cpp Mon Oct 22 12:33:31 2012
> @@ -127,7 +127,7 @@
> uint64_t EncodedAttrs = Attrs.Raw() & 0xffff;
> if (Attrs.hasAttribute(Attributes::Alignment))
> EncodedAttrs |= Attrs.getAlignment() << 16;
> - EncodedAttrs |= (Attrs.Raw() & (0xfffULL << 21)) << 11;
> + EncodedAttrs |= (Attrs.Raw() & (0xffffULL << 21)) << 11;
> return EncodedAttrs;
> }
>
> @@ -145,7 +145,7 @@
> AttrBuilder B(EncodedAttrs & 0xffff);
> if (Alignment)
> B.addAlignmentAttr(Alignment);
> - B.addRawValue((EncodedAttrs & (0xfffULL << 32)) >> 11);
> + B.addRawValue((EncodedAttrs & (0xffffULL << 32)) >> 11);
> return Attributes::get(C, B);
> }
>
> @@ -201,6 +201,8 @@
> Result += "nonlazybind ";
> if (hasAttribute(Attributes::AddressSafety))
> Result += "address_safety ";
> + if (hasAttribute(Attributes::ForceSizeOpt))
> + Result += "forcesizeopt ";
> if (hasAttribute(Attributes::StackAlignment)) {
> Result += "alignstack(";
> Result += utostr(getStackAlignment());
> @@ -324,6 +326,7 @@
> case Attributes::UWTable: return 1 << 30;
> case Attributes::NonLazyBind: return 1U << 31;
> case Attributes::AddressSafety: return 1ULL << 32;
> + case Attributes::ForceSizeOpt: return 1ULL << 33;
> }
> llvm_unreachable("Unsupported attribute type");
> }
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits
More information about the llvm-commits
mailing list