Change ForceSizeOpt attribute into MinSize attribute

llvm-svn: 167020
This commit is contained in:
Quentin Colombet 2012-10-30 16:32:52 +00:00
parent bce56286fb
commit dde058d386
10 changed files with 24 additions and 23 deletions

View File

@ -58,9 +58,9 @@ public:
///< 0 means unaligned different from align 1 ///< 0 means unaligned different from align 1
AlwaysInline, ///< inline=always AlwaysInline, ///< inline=always
ByVal, ///< Pass structure by value ByVal, ///< Pass structure by value
ForceSizeOpt, ///< Function must be optimized for size first
InlineHint, ///< Source said inlining was desirable InlineHint, ///< Source said inlining was desirable
InReg, ///< Force argument to be passed in register InReg, ///< Force argument to be passed in register
MinSize, ///< Function must be optimized for size first
Naked, ///< Naked function Naked, ///< Naked function
Nest, ///< Nested function static chain Nest, ///< Nested function static chain
NoAlias, ///< Considered to not alias after call NoAlias, ///< Considered to not alias after call
@ -154,7 +154,7 @@ public:
hasAttribute(Attributes::NonLazyBind) || hasAttribute(Attributes::NonLazyBind) ||
hasAttribute(Attributes::ReturnsTwice) || hasAttribute(Attributes::ReturnsTwice) ||
hasAttribute(Attributes::AddressSafety) || hasAttribute(Attributes::AddressSafety) ||
hasAttribute(Attributes::ForceSizeOpt); hasAttribute(Attributes::MinSize);
} }
bool operator==(const Attributes &A) const { bool operator==(const Attributes &A) const {
@ -266,7 +266,7 @@ public:
.removeAttribute(Attributes::NonLazyBind) .removeAttribute(Attributes::NonLazyBind)
.removeAttribute(Attributes::ReturnsTwice) .removeAttribute(Attributes::ReturnsTwice)
.removeAttribute(Attributes::AddressSafety) .removeAttribute(Attributes::AddressSafety)
.removeAttribute(Attributes::ForceSizeOpt); .removeAttribute(Attributes::MinSize);
} }
uint64_t Raw() const { return Bits; } uint64_t Raw() const { return Bits; }

View File

@ -558,7 +558,7 @@ lltok::Kind LLLexer::LexIdentifier() {
KEYWORD(naked); KEYWORD(naked);
KEYWORD(nonlazybind); KEYWORD(nonlazybind);
KEYWORD(address_safety); KEYWORD(address_safety);
KEYWORD(forcesizeopt); KEYWORD(minsize);
KEYWORD(type); KEYWORD(type);
KEYWORD(opaque); KEYWORD(opaque);

View File

@ -953,7 +953,7 @@ bool LLParser::ParseOptionalAttrs(AttrBuilder &B, unsigned AttrKind) {
case lltok::kw_naked: B.addAttribute(Attributes::Naked); break; case lltok::kw_naked: B.addAttribute(Attributes::Naked); break;
case lltok::kw_nonlazybind: B.addAttribute(Attributes::NonLazyBind); break; case lltok::kw_nonlazybind: B.addAttribute(Attributes::NonLazyBind); break;
case lltok::kw_address_safety: B.addAttribute(Attributes::AddressSafety); 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: { case lltok::kw_alignstack: {
unsigned Alignment; unsigned Alignment;
@ -1012,7 +1012,7 @@ bool LLParser::ParseOptionalAttrs(AttrBuilder &B, unsigned AttrKind) {
case lltok::kw_nonlazybind: case lltok::kw_nonlazybind:
case lltok::kw_returns_twice: case lltok::kw_returns_twice:
case lltok::kw_address_safety: case lltok::kw_address_safety:
case lltok::kw_forcesizeopt: case lltok::kw_minsize:
if (AttrKind != 2) if (AttrKind != 2)
HaveError |= Error(AttrLoc, "invalid use of function-only attribute"); HaveError |= Error(AttrLoc, "invalid use of function-only attribute");
break; break;

View File

@ -110,7 +110,7 @@ namespace lltok {
kw_naked, kw_naked,
kw_nonlazybind, kw_nonlazybind,
kw_address_safety, kw_address_safety,
kw_forcesizeopt, kw_minsize,
kw_type, kw_type,
kw_opaque, kw_opaque,

View File

@ -1594,15 +1594,15 @@ ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
// FIXME: handle tail calls differently. // FIXME: handle tail calls differently.
unsigned CallOpc; unsigned CallOpc;
bool HasForceSizeAttr = MF.getFunction()->getFnAttributes(). bool HasMinSizeAttr = MF.getFunction()->getFnAttributes().
hasAttribute(Attributes::ForceSizeOpt); hasAttribute(Attributes::MinSize);
if (Subtarget->isThumb()) { if (Subtarget->isThumb()) {
if ((!isDirect || isARMFunc) && !Subtarget->hasV5TOps()) if ((!isDirect || isARMFunc) && !Subtarget->hasV5TOps())
CallOpc = ARMISD::CALL_NOLINK; CallOpc = ARMISD::CALL_NOLINK;
else if (doesNotRet && isDirect && !isARMFunc && else if (doesNotRet && isDirect && !isARMFunc &&
Subtarget->hasRAS() && !Subtarget->isThumb1Only() && Subtarget->hasRAS() && !Subtarget->isThumb1Only() &&
// Emit regular call when code size is the priority // Emit regular call when code size is the priority
!HasForceSizeAttr) !HasMinSizeAttr)
// "mov lr, pc; b _foo" to avoid confusing the RSP // "mov lr, pc; b _foo" to avoid confusing the RSP
CallOpc = ARMISD::CALL_NOLINK; CallOpc = ARMISD::CALL_NOLINK;
else else
@ -1612,7 +1612,7 @@ ARMTargetLowering::LowerCall(TargetLowering::CallLoweringInfo &CLI,
CallOpc = ARMISD::CALL_NOLINK; CallOpc = ARMISD::CALL_NOLINK;
} else if (doesNotRet && isDirect && Subtarget->hasRAS() && } else if (doesNotRet && isDirect && Subtarget->hasRAS() &&
// Emit regular call when code size is the priority // Emit regular call when code size is the priority
!HasForceSizeAttr) !HasMinSizeAttr)
// "mov lr, pc; b _foo" to avoid confusing the RSP // "mov lr, pc; b _foo" to avoid confusing the RSP
CallOpc = ARMISD::CALL_NOLINK; CallOpc = ARMISD::CALL_NOLINK;
else else

View File

@ -507,6 +507,7 @@ void CppWriter::printAttributes(const AttrListPtr &PAL,
HANDLE_ATTR(ReturnsTwice); HANDLE_ATTR(ReturnsTwice);
HANDLE_ATTR(UWTable); HANDLE_ATTR(UWTable);
HANDLE_ATTR(NonLazyBind); HANDLE_ATTR(NonLazyBind);
HANDLE_ATTR(MinSize);
#undef HANDLE_ATTR #undef HANDLE_ATTR
if (attrs.hasAttribute(Attributes::StackAlignment)) if (attrs.hasAttribute(Attributes::StackAlignment))
Out << " B.addStackAlignmentAttr(" << attrs.getStackAlignment() << ")\n"; Out << " B.addStackAlignmentAttr(" << attrs.getStackAlignment() << ")\n";

View File

@ -201,8 +201,8 @@ std::string Attributes::getAsString() const {
Result += "nonlazybind "; Result += "nonlazybind ";
if (hasAttribute(Attributes::AddressSafety)) if (hasAttribute(Attributes::AddressSafety))
Result += "address_safety "; Result += "address_safety ";
if (hasAttribute(Attributes::ForceSizeOpt)) if (hasAttribute(Attributes::MinSize))
Result += "forcesizeopt "; Result += "minsize ";
if (hasAttribute(Attributes::StackAlignment)) { if (hasAttribute(Attributes::StackAlignment)) {
Result += "alignstack("; Result += "alignstack(";
Result += utostr(getStackAlignment()); Result += utostr(getStackAlignment());
@ -326,7 +326,7 @@ uint64_t AttributesImpl::getAttrMask(uint64_t Val) {
case Attributes::UWTable: return 1 << 30; case Attributes::UWTable: return 1 << 30;
case Attributes::NonLazyBind: return 1U << 31; case Attributes::NonLazyBind: return 1U << 31;
case Attributes::AddressSafety: return 1ULL << 32; case Attributes::AddressSafety: return 1ULL << 32;
case Attributes::ForceSizeOpt: return 1ULL << 33; case Attributes::MinSize: return 1ULL << 33;
} }
llvm_unreachable("Unsupported attribute type"); llvm_unreachable("Unsupported attribute type");
} }

View File

@ -3,7 +3,7 @@
; RUN: llc < %s -mtriple=thumbv7-apple-ios -mcpu=cortex-a8 | FileCheck %s -check-prefix=T2 ; RUN: llc < %s -mtriple=thumbv7-apple-ios -mcpu=cortex-a8 | FileCheck %s -check-prefix=T2
; rdar://12348580 ; rdar://12348580
define void @t1() noreturn forcesizeopt nounwind ssp { define void @t1() noreturn minsize nounwind ssp {
entry: entry:
; ARM: t1: ; ARM: t1:
; ARM: bl _bar ; ARM: bl _bar
@ -17,7 +17,7 @@ entry:
unreachable unreachable
} }
define void @t2() noreturn forcesizeopt nounwind ssp { define void @t2() noreturn minsize nounwind ssp {
entry: entry:
; ARM: t2: ; ARM: t2:
; ARM: bl _t1 ; ARM: bl _t1

View File

@ -1,7 +0,0 @@
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
define void @test1() forcesizeopt {
; CHECK: define void @test1() forcesizeopt
ret void
}

View File

@ -0,0 +1,7 @@
; RUN: llvm-as < %s | llvm-dis | FileCheck %s
define void @test1() minsize {
; CHECK: define void @test1() minsize
ret void
}